Commit 679b4ef6 by zacharyc

Fixed a few bugs to increase reliability and drop first line.


git-svn-id: https://bucket.mit.edu/svn/nilm/acquisition/ethstream@7262 ddd99763-3ecb-0310-9145-efcb8ce7c51f
parent 770a83b8
Showing with 12 additions and 1 deletions
......@@ -359,6 +359,7 @@ int nerdDoStream(const char *address, int *channel_list, int channel_count, int
int retval = -EAGAIN;
int fd_data;
static int first_call = 1;
static int started = 0;
char command[14];
static unsigned short currentcount = 0;
......@@ -386,7 +387,7 @@ int nerdDoStream(const char *address, int *channel_list, int channel_count, int
first_call = 0;
//If we had a transmission in progress, send a command to resume from there
if(currentcount != 0) {
if(started == 1) {
char cmdbuf[10];
sprintf(cmdbuf,"SETC%05hd",currentcount);
if (nerd_send_command(address,cmdbuf) < 0) {
......@@ -395,6 +396,8 @@ int nerdDoStream(const char *address, int *channel_list, int channel_count, int
}
}
started = 1;
/* Open connection */
fd_data = nerd_open(address, NERDJACK_DATA_PORT);
if (fd_data < 0) {
......
......@@ -211,6 +211,7 @@ int nerd_data_stream(int data_fd, int numChannels, int *channel_list, int precis
//Variables that should persist across retries
static unsigned char buf[NERDJACK_PACKET_SIZE];
static int linesleft = 0;
static int linesdumped = 0;
int index = 0;
int alignment = 0;
......@@ -322,6 +323,7 @@ int nerd_data_stream(int data_fd, int numChannels, int *channel_list, int precis
//Since channel data is packed, we need to know when to insert a newline
if(alignment == numChannelsSampled){
if(linesdumped != 0){
switch(convert) {
case CONVERT_VOLTS:
for(i = 0; i < numChannels; i++) {
......@@ -345,6 +347,12 @@ int nerd_data_stream(int data_fd, int numChannels, int *channel_list, int precis
}
if(printf("\n") < 0)
goto bad;
} else {
linesdumped = linesdumped + 1;
if(lines != 0) {
linesleft++;
}
}
alignment = 0;
numgroups++;
if(lines != 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment