git-svn-id: https://bucket.mit.edu/svn/nilm/acquisition/ethstream@7415 ddd99763-3ecb-0310-9145-efcb8ce7c51ftags/ethstream-1.1
@@ -421,6 +421,7 @@ nerdDoStream (const char *address, int *channel_list, int channel_count, | |||
int fd_data; | |||
static int first_call = 1; | |||
static int started = 0; | |||
static int wasreset = 0; | |||
getPacket command; | |||
static unsigned short currentcount = 0; | |||
@@ -463,6 +464,7 @@ nerdDoStream (const char *address, int *channel_list, int channel_count, | |||
printf("# NerdJack was reset here\n"); | |||
currentcount = 0; | |||
started = 0; | |||
wasreset = 1; | |||
goto out; | |||
} else if(retval < 0) { | |||
info ("Failed to send SETC command\n"); | |||
@@ -483,7 +485,8 @@ nerdDoStream (const char *address, int *channel_list, int channel_count, | |||
retval = nerd_data_stream | |||
(fd_data, channel_count, channel_list, precision, convert, lines, | |||
showmem, ¤tcount, period); | |||
showmem, ¤tcount, period, wasreset); | |||
wasreset = 0; | |||
if(retval == -3) | |||
{ | |||
retval = 0; | |||
@@ -39,7 +39,6 @@ typedef struct __attribute__ ((__packed__)) | |||
unsigned char headerone; | |||
unsigned char headertwo; | |||
unsigned short packetNumber; | |||
unsigned long lwipmemoryused; | |||
unsigned short adcused; | |||
unsigned short packetsready; | |||
signed short data[NERDJACK_NUM_SAMPLES]; | |||
@@ -263,7 +262,8 @@ nerd_init_channels (deststruct * destination, int numChannels, | |||
int | |||
nerd_data_stream (int data_fd, int numChannels, int *channel_list, | |||
int precision, int convert, int lines, int showmem, | |||
unsigned short *currentcount, unsigned int period) | |||
unsigned short *currentcount, unsigned int period, | |||
int wasreset) | |||
{ | |||
//Variables that should persist across retries | |||
static dataPacket buf; | |||
@@ -279,7 +279,7 @@ nerd_data_stream (int data_fd, int numChannels, int *channel_list, | |||
int i; | |||
unsigned long memused = 0; | |||
//unsigned long memused = 0; | |||
unsigned short packetsready = 0; | |||
unsigned short adcused = 0; | |||
unsigned short tempshort = 0; | |||
@@ -300,6 +300,10 @@ nerd_data_stream (int data_fd, int numChannels, int *channel_list, | |||
linesleft = lines; | |||
} | |||
if(wasreset) { | |||
linesdumped = 0; | |||
} | |||
int numChannelsSampled = channel_list[0] + 1; | |||
@@ -368,20 +372,20 @@ nerd_data_stream (int data_fd, int numChannels, int *channel_list, | |||
//Process the rest of the header and update the index value to be pointing after it | |||
charsprocessed = 12; | |||
memused = ntohl (buf.lwipmemoryused); | |||
//memused = ntohl (buf.lwipmemoryused); | |||
adcused = ntohs (buf.adcused); | |||
packetsready = ntohs (buf.packetsready); | |||
alignment = 0; | |||
numgroups = 0; | |||
if(memused) { | |||
printf("#Packet lost\n"); | |||
continue; | |||
} | |||
//if(memused) { | |||
// printf("#Packet lost\n"); | |||
// continue; | |||
//} | |||
if (showmem) | |||
{ | |||
printf ("%lX %hd %hd\n", memused, adcused, packetsready); | |||
printf ("%hd %hd\n", adcused, packetsready); | |||
continue; | |||
} | |||
@@ -16,13 +16,13 @@ | |||
#include "netutil.h" | |||
#define NERDJACK_CHANNELS 12 | |||
#define NERDJACK_CLOCK_RATE 54000000 | |||
#define NERDJACK_CLOCK_RATE 66000000 | |||
#define NERDJACK_DATA_PORT 49155 | |||
#define NERDJACK_UDP_RECEIVE_PORT 49156 | |||
#define NERDJACK_COMMAND_PORT 49157 | |||
#define NERDJACK_PACKET_SIZE 1460 | |||
#define NERDJACK_NUM_SAMPLES 724 | |||
#define NERDJACK_NUM_SAMPLES 726 | |||
/* Packet structure used in message to start sampling on NerdJack */ | |||
typedef struct __attribute__ ((__packed__)) | |||
@@ -49,7 +49,8 @@ int nerd_send_command (const char *address, void *command, int length); | |||
/* Stream data out of the NerdJack */ | |||
int nerd_data_stream (int data_fd, int numChannels, int *channel_list, | |||
int precision, int convert, int lines, int showmem, | |||
unsigned short *currentcount, unsigned int period); | |||
unsigned short *currentcount, unsigned int period, | |||
int wasreset); | |||
/* Detect the IP Address of the NerdJack and return in ipAddress */ | |||
int nerdjack_detect (char *ipAddress); | |||