diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-07-17 18:37:38 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-07-17 18:37:38 +0200 |
| commit | 5d7436ba49bae51389e168b5d43f297fe0ccda7c (patch) | |
| tree | cf05800aaae0979e0e6a02fdb7ce40fc55fc1367 | |
| parent | 76f13c34f390e7dbbadb2051cda316f0060bdbff (diff) | |
Minor changes
| -rw-r--r-- | config.mk | 2 | ||||
| -rw-r--r-- | src/logger.c | 8 | ||||
| -rw-r--r-- | src/subscriber.c | 2 | ||||
| -rw-r--r-- | src/utils.h | 1 |
4 files changed, 7 insertions, 6 deletions
@@ -19,7 +19,7 @@ LOGGERS_DIR=/tmp/ina260_logs/ # LOGGERS_DELAY defines the delay between 2 consecutive # ina260 power read performed by the logger # Unit is milliseconds -LOGGERS_DELAY=0 +LOGGERS_DELAY=1000 # SUBSCRIBER_DIR will contain all the measurments # received from the publishers SUBSCRIBER_DIR=./data diff --git a/src/logger.c b/src/logger.c index 4258090..d09220e 100644 --- a/src/logger.c +++ b/src/logger.c @@ -114,14 +114,14 @@ int main (int argc, char *argv []) fgets(buffer,STATIC_LEN,regptr); // Get power measurement timestamp: clock_gettime(CLOCK_REALTIME,&power_ts); - char line[STATIC_LEN]; + 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+linelen)>ZMQ_MSG_SIZE){ + if((queues[queue_id].size+MAX_RECORD_LEN)>ZMQ_MSG_SIZE){ printf("To many measurements to publish. Please increase ZMQ_MSG_SIZE\n"); } else { - memcpy(queues[queue_id].msg+queues[queue_id].size,line,linelen); - queues[queue_id].size+=linelen; + sprintf(queues[queue_id].msg+queues[queue_id].size,"%ld,%ld,%d\n",power_ts.tv_sec,power_ts.tv_nsec,atoi(buffer)); + queues[queue_id].size+=strlen(queues[queue_id].msg+queues[queue_id].size); } // Reset power register file: fseek(regptr,0,SEEK_SET); diff --git a/src/subscriber.c b/src/subscriber.c index eb9a700..1024041 100644 --- a/src/subscriber.c +++ b/src/subscriber.c @@ -79,7 +79,7 @@ int main (int argc, char *argv []) // Write all the measurements: if(line>4){ fwrite(token, strlen(token), 1, fptr); - //printf("%s\n",token); + printf("%s\n",token); fwrite("\n",1,1,fptr); } diff --git a/src/utils.h b/src/utils.h index f27ff9e..2f5f82a 100644 --- a/src/utils.h +++ b/src/utils.h @@ -10,6 +10,7 @@ #define INA260_SYSFS "/sys/kernel/ina260" #define INA260_POWER_REGISTER "registers/power" #define STATIC_LEN 255 +#define MAX_RECORD_LEN 100 #define MAX_QUEUES 1 #ifndef ZMQ_TOKEN |
