cli: fix get allways returning 8 channels
This commit is contained in:
parent
1f40693c19
commit
4efb15d098
1 changed files with 8 additions and 1 deletions
9
main.c
9
main.c
|
|
@ -156,8 +156,15 @@ static int process_commands(char** commands, size_t command_count, struct eismul
|
||||||
}
|
}
|
||||||
else if(strcmp(commands[0], "get") == 0)
|
else if(strcmp(commands[0], "get") == 0)
|
||||||
{
|
{
|
||||||
|
uint16_t count;
|
||||||
|
int ret = eismultiplexer_get_channel_count(multiplexer, &count);
|
||||||
|
if(ret < 0)
|
||||||
|
{
|
||||||
|
printf("could not get the number of channels\n");
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
channel_t channels = eismultiplexer_get_connected(multiplexer);
|
channel_t channels = eismultiplexer_get_connected(multiplexer);
|
||||||
for(size_t i = 0; i < 7; ++i)
|
for(size_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
bool connected = channels & (1 << i);
|
bool connected = channels & (1 << i);
|
||||||
printf("Channel %c: %s\n", (char)('A'+i), connected ? "on" : "off");
|
printf("Channel %c: %s\n", (char)('A'+i), connected ? "on" : "off");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue