diff --git a/client/spice/messages.h b/client/spice/messages.h index 87fe29d5..8be1dc4f 100644 --- a/client/spice/messages.h +++ b/client/spice/messages.h @@ -40,10 +40,17 @@ typedef struct SpiceMsgMainInit } SpiceMsgMainInit; +typedef struct SpiceChannelID +{ + uint8_t type; + uint8_t channel_id; +} +SpiceChannelID; + typedef struct SpiceMsgMainChannelsList { uint32_t num_of_channels; - //uint8_t channels[num_of_channels] + //SpiceChannelID channels[num_of_channels] } SpiceMainChannelsList; diff --git a/client/spice/spice.c b/client/spice/spice.c index e3c77dec..43948c9a 100644 --- a/client/spice/spice.c +++ b/client/spice/spice.c @@ -442,8 +442,8 @@ bool spice_on_main_channel_read() } // documentation doesn't state that the array is null terminated but it seems that it is - uint8_t channels[msg.num_of_channels+1]; - if (!spice_read(channel, &channels, msg.num_of_channels+1)) + SpiceChannelID channels[msg.num_of_channels]; + if (!spice_read(channel, &channels, msg.num_of_channels * sizeof(SpiceChannelID))) { DEBUG_ERROR("Failed to read channel list vector"); spice_disconnect(); @@ -452,8 +452,8 @@ bool spice_on_main_channel_read() for(int i = 0; i < msg.num_of_channels; ++i) { - DEBUG_PROTO("channel %d = %u", i, channels[i]); - if (channels[i] == SPICE_CHANNEL_INPUTS) + DEBUG_PROTO("channel %d = %u", i, channels[i].type); + if (channels[i].type == SPICE_CHANNEL_INPUTS) { if (spice.scInputs.connected) {