Mercurial > hg > fxanalyse
diff kk-data-provider.c @ 91:4102fe614df2
Fix timestamping. Cleanup data providers
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Fri, 22 Mar 2013 16:32:15 +0100 |
parents | c9e4f63c2033 |
children | b7ae2d947617 |
line wrap: on
line diff
--- a/kk-data-provider.c Fri Mar 22 18:49:58 2013 +0100 +++ b/kk-data-provider.c Fri Mar 22 16:32:15 2013 +0100 @@ -4,24 +4,17 @@ #include <userint.h> #include <formatio.h> #include <utility.h> + +#include "data-provider.h" #include "KKFX80E.h" #define SERIAL "COM1:115200" -/* data acquisition flag */ -extern int acquiring; -/* data queue */ -extern CmtTSQHandle dataQueue; -/* callback receiving messages in the main thread */ -void CVICALLBACK MessageCB (void *callbackData); -/* message */ -char message[1024]; - int CVICALLBACK KKDataProvider (void *functionData) { int mainThreadId; char *resp; - double data[5]; + struct event event; /* get main thread id to post messages to it */ mainThreadId = CmtGetMainThreadID(); @@ -54,26 +47,26 @@ if (strncmp(resp, "2900;", 5) == 0) { /* timestamp */ - GetCurrentDateTime(&data[0]); + gettimeofday(&event.time, NULL); /* parse received data */ - Scan(resp, "2900; %f; %f; %f; %f", &data[1], &data[2], &data[3], &data[4]); + Scan(resp, "2900; %f; %f; %f; %f", + &event.data[0], &event.data[1], &event.data[2], &event.data[3]); /* convert from kHz to Hz */ - data[1] = data[1] * 1000.0; - data[2] = data[2] * 1000.0; - data[3] = data[3] * 1000.0; - data[4] = data[4] * 1000.0; + event.data[0] *= 1000.0; + event.data[1] *= 1000.0; + event.data[2] *= 1000.0; + event.data[3] *= 1000.0; /* push data into the data queue */ - CmtWriteTSQData(dataQueue, data, 5, TSQ_INFINITE_TIMEOUT, 0); + CmtWriteTSQData(dataQueue, &event, 1, TSQ_INFINITE_TIMEOUT, 0); } else if (strncmp(resp, "7000;", 5) == 0) { /* ignore heart beat response */ } else { /* send message to the main thread */ - strncpy(message, resp, sizeof(message)); - PostDeferredCallToThread(MessageCB, message, mainThreadId); + SendMessage(mainThreadId, resp); } }