diff --git a/main.c b/main.c index d1c482b..7c9eb31 100644 --- a/main.c +++ b/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) { + 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); - for(size_t i = 0; i < 7; ++i) + for(size_t i = 0; i < count; ++i) { bool connected = channels & (1 << i); printf("Channel %c: %s\n", (char)('A'+i), connected ? "on" : "off");