summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.mk4
-rw-r--r--src/logger.c8
2 files changed, 11 insertions, 1 deletions
diff --git a/config.mk b/config.mk
index 4ad0dbf..d1f1e9e 100644
--- a/config.mk
+++ b/config.mk
@@ -15,6 +15,10 @@ ZMQ_MSG_SIZE=2550
# LOGGERS_DIR will contains all the data generated by the loggers
# a.k.a the ina260 power measurements
LOGGERS_DIR=./logs
+# LOGGER_DELAY defines the delay between 2 consecutive
+# ina260 power read performed by the logger
+# Unit is milliseconds
+LOGGER_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 9ed974e..b22037d 100644
--- a/src/logger.c
+++ b/src/logger.c
@@ -9,6 +9,10 @@
#include "utils.h"
#include <time.h>
+#ifndef LOGGER_DELAY
+#define LOGGER_DELAY 0
+#endif
+
// Global:
char *__client;
char __logdir[255];
@@ -70,7 +74,9 @@ int main (int argc, char *argv [])
clock_gettime(CLOCK_REALTIME,&power_ts);
fprintf(logptr,"%d,%ld,%d\n",power_ts.tv_sec,power_ts.tv_nsec,power);
fseek(regptr,0,SEEK_SET);
- sleep(1);
+#if LOGGER_DELAY > 0
+ usleep(LOGGER_DELAY*1000);
+#endif
printf("Tick\n"); fflush(stdout);
}
fclose(logptr);