Mercurial > hg > fxanalyse
diff kk-data-provider.c @ 96:4a11331eacbf
Ignore packet with id '7015' in KK driver
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Tue, 26 Mar 2013 18:17:18 +0100 |
parents | b7ae2d947617 |
children | 4f1f353e84f5 |
line wrap: on
line diff
--- a/kk-data-provider.c Fri Mar 22 18:55:08 2013 +0100 +++ b/kk-data-provider.c Tue Mar 26 18:17:18 2013 +0100 @@ -12,9 +12,12 @@ #define CONFIGFILE "FXAnalise.ini" #define DEFAULTPORT "COM4:115200" +#define strneq(a, b, len) (strncmp((a), (b), (len)) == 0) + int CVICALLBACK KKDataProvider (void *functionData) { int mainThreadId; + int rv; char *resp; struct event event; char port[256]; @@ -22,7 +25,7 @@ /* get main thread id to post messages to it */ mainThreadId = CmtGetMainThreadID(); - /* path for the configuration file */ + /* construct configuration file path */ char pathname[MAX_PATHNAME_LEN]; char project[MAX_PATHNAME_LEN]; GetProjectDir(project); @@ -33,7 +36,7 @@ Ini_ReadFromFile(configuration, pathname); /* get serial port name configuration */ - int rv = Ini_GetStringIntoBuffer(configuration, "KK", "port", port, sizeof(port)); + rv = Ini_GetStringIntoBuffer(configuration, "KK", "port", port, sizeof(port)); if (rv == 0) strncpy(port, DEFAULTPORT, sizeof(port)); @@ -43,7 +46,7 @@ /* initialize library */ FX_Init(); /* connect to KK FX80E counter */ - FX_Open(port); + rv = FX_Open(port); /* clear transmit buffer */ FX_Send("\x80"); @@ -65,7 +68,7 @@ /* receive data from counter */ FX_Recv(&resp); - if (strncmp(resp, "2900;", 5) == 0) { + if (strneq(resp, "2900;", 5)) { /* timestamp */ gettimeofday(&event.time, NULL); @@ -82,9 +85,13 @@ /* push data into the data queue */ CmtWriteTSQData(dataQueue, &event, 1, TSQ_INFINITE_TIMEOUT, 0); - - } else if (strncmp(resp, "7000;", 5) == 0) { - /* ignore heart beat response */ + + } else if (strneq(resp, "7000;", 5)) { + /* ignore heart beat packet */ + } else if (strneq(resp, "7015;", 5)) { + /* ignore undocumented packet. it is sent by newer kk counters + for each data packet. it contains a sample count along with + other information */ } else { /* send message to the main thread */ SendMessage(mainThreadId, resp);