Minor changes

This commit is contained in:
Loic Guegan 2023-07-17 18:41:23 +02:00
parent 5d7436ba49
commit a6a3304fed
3 changed files with 5 additions and 2 deletions

View file

@ -115,8 +115,6 @@ int main (int argc, char *argv [])
// Get power measurement timestamp:
clock_gettime(CLOCK_REALTIME,&power_ts);
char line[MAX_RECORD_LEN];
sprintf(line,"%ld,%ld,%d\n",power_ts.tv_sec,power_ts.tv_nsec,atoi(buffer));
int linelen=strlen(line);
if((queues[queue_id].size+MAX_RECORD_LEN)>ZMQ_MSG_SIZE){
printf("To many measurements to publish. Please increase ZMQ_MSG_SIZE\n");
} else {

View file

@ -73,7 +73,11 @@ int main (int argc, char *argv [])
}
// Now open output file:
sprintf(path,"%s/%s/%s/%ld",cdatadir,key,client,interval);
char exists=FILE_EXISTS(path);
fptr=fopen(path,"a");
if(!exists){
fwrite(CSV_HEADER"\n", strlen(CSV_HEADER)+1, 1, fptr);
}
}
// Write all the measurements:

View file

@ -12,6 +12,7 @@
#define STATIC_LEN 255
#define MAX_RECORD_LEN 100
#define MAX_QUEUES 1
#define CSV_HEADER "timestamp,nsecs,power"
#ifndef ZMQ_TOKEN
#define ZMQ_TOKEN "ina260-zmq-publisher"