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 ...@@ -359,6 +359,7 @@ int nerdDoStream(const char *address, int *channel_list, int channel_count, int
int retval = -EAGAIN; int retval = -EAGAIN;
int fd_data; int fd_data;
static int first_call = 1; static int first_call = 1;
static int started = 0;
char command[14]; char command[14];
static unsigned short currentcount = 0; static unsigned short currentcount = 0;
...@@ -386,7 +387,7 @@ int nerdDoStream(const char *address, int *channel_list, int channel_count, int ...@@ -386,7 +387,7 @@ int nerdDoStream(const char *address, int *channel_list, int channel_count, int
first_call = 0; first_call = 0;
//If we had a transmission in progress, send a command to resume from there //If we had a transmission in progress, send a command to resume from there
if(currentcount != 0) { if(started == 1) {
char cmdbuf[10]; char cmdbuf[10];
sprintf(cmdbuf,"SETC%05hd",currentcount); sprintf(cmdbuf,"SETC%05hd",currentcount);
if (nerd_send_command(address,cmdbuf) < 0) { if (nerd_send_command(address,cmdbuf) < 0) {
...@@ -395,6 +396,8 @@ int nerdDoStream(const char *address, int *channel_list, int channel_count, int ...@@ -395,6 +396,8 @@ int nerdDoStream(const char *address, int *channel_list, int channel_count, int
} }
} }
started = 1;
/* Open connection */ /* Open connection */
fd_data = nerd_open(address, NERDJACK_DATA_PORT); fd_data = nerd_open(address, NERDJACK_DATA_PORT);
if (fd_data < 0) { if (fd_data < 0) {
......
...@@ -211,6 +211,7 @@ int nerd_data_stream(int data_fd, int numChannels, int *channel_list, int precis ...@@ -211,6 +211,7 @@ int nerd_data_stream(int data_fd, int numChannels, int *channel_list, int precis
//Variables that should persist across retries //Variables that should persist across retries
static unsigned char buf[NERDJACK_PACKET_SIZE]; static unsigned char buf[NERDJACK_PACKET_SIZE];
static int linesleft = 0; static int linesleft = 0;
static int linesdumped = 0;
int index = 0; int index = 0;
int alignment = 0; int alignment = 0;
...@@ -322,6 +323,7 @@ int nerd_data_stream(int data_fd, int numChannels, int *channel_list, int precis ...@@ -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 //Since channel data is packed, we need to know when to insert a newline
if(alignment == numChannelsSampled){ if(alignment == numChannelsSampled){
if(linesdumped != 0){
switch(convert) { switch(convert) {
case CONVERT_VOLTS: case CONVERT_VOLTS:
for(i = 0; i < numChannels; i++) { for(i = 0; i < numChannels; i++) {
...@@ -345,6 +347,12 @@ int nerd_data_stream(int data_fd, int numChannels, int *channel_list, int precis ...@@ -345,6 +347,12 @@ int nerd_data_stream(int data_fd, int numChannels, int *channel_list, int precis
} }
if(printf("\n") < 0) if(printf("\n") < 0)
goto bad; goto bad;
} else {
linesdumped = linesdumped + 1;
if(lines != 0) {
linesleft++;
}
}
alignment = 0; alignment = 0;
numgroups++; numgroups++;
if(lines != 0) { 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