Browse Source

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
tags/ethstream-1.1
zacharyc 15 years ago
parent
commit
679b4ef64f
2 changed files with 12 additions and 1 deletions
  1. +4
    -1
      ethstream.c
  2. +8
    -0
      nerdjack.c

+ 4
- 1
ethstream.c View File

@@ -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) {
@@ -394,6 +395,8 @@ int nerdDoStream(const char *address, int *channel_list, int channel_count, int
goto out;
}
}

started = 1;
/* Open connection */
fd_data = nerd_open(address, NERDJACK_DATA_PORT);


+ 8
- 0
nerdjack.c View File

@@ -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) {


Loading…
Cancel
Save