From b9130788f2e4c2e7ca4c3d3c3ca88b57021d6544 Mon Sep 17 00:00:00 2001 From: nilm Date: Thu, 9 Apr 2009 22:00:15 +0000 Subject: [PATCH] Fixed annoying bug with NerdJack header git-svn-id: https://bucket.mit.edu/svn/nilm/acquisition/ethstream@7419 ddd99763-3ecb-0310-9145-efcb8ce7c51f --- nerdjack.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nerdjack.c b/nerdjack.c index c482fc8..c617467 100644 --- a/nerdjack.c +++ b/nerdjack.c @@ -34,6 +34,8 @@ typedef struct int *destlist; } deststruct; +#define NERD_HEADER_SIZE 8 + typedef struct __attribute__ ((__packed__)) { unsigned char headerone; @@ -371,7 +373,7 @@ nerd_data_stream (int data_fd, int numChannels, int *channel_list, *currentcount = *currentcount + 1; //Process the rest of the header and update the index value to be pointing after it - charsprocessed = 12; + charsprocessed = NERD_HEADER_SIZE; //memused = ntohl (buf.lwipmemoryused); adcused = ntohs (buf.adcused); packetsready = ntohs (buf.packetsready); @@ -570,12 +572,20 @@ nerd_generate_command (getPacket * command, int *channel_list, short channelbit = 0; int i; + int highestchannel = 0; for (i = 0; i < channel_count; i++) { - channelbit = channelbit | (0x1 << channel_list[i]); + if (channel_list[i] > highestchannel) { + highestchannel = channel_list[i]; + } + //channelbit = channelbit | (0x1 << channel_list[i]); } + for( i = 0; i <= highestchannel; i++) { + channelbit = channelbit | (0x01 << i); + } + command->word[0] = 'G'; command->word[1] = 'E'; command->word[2] = 'T';