Commit 519a0c2e by nilm

Made changes to ethstream to work with new clock


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