From 267d9a07255d96a564da64ce5c819ebc4701d5f1 Mon Sep 17 00:00:00 2001 From: Jonathan McCrohan Date: Mon, 12 Mar 2012 23:37:21 +0000 Subject: Force log upon startup --- src/modbuslog.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modbuslog.c b/src/modbuslog.c index 4c8ac60..5142646 100644 --- a/src/modbuslog.c +++ b/src/modbuslog.c @@ -141,6 +141,10 @@ int main(int argc, char *argv[]) { int rc; int i; + // used to force a reading 2 mins after power on + int firstrun; + firstrun = 1; + // SIGALRM used to wake for loop up every 60 secs // sleep puts whole thread to sleep which isn't what we want // other methods involve CPU spinlocks which are inefficient @@ -201,8 +205,8 @@ int main(int argc, char *argv[]) { else intervalduration = intervalvalue * 60; - // if we match the required time for the reading - if (unixtime_min % intervalduration == 0) { + // if we match the required time for the reading or first run + if ((unixtime_min % intervalduration == 0)||firstrun) { //printf("specified minute. %d %d\n", unixtime_min, // intervalduration); @@ -383,6 +387,8 @@ int main(int argc, char *argv[]) { } //printf("%d ", slaveid); } + // revert to normal timing + firstrun=0; //printf("%d\n", unixtime_min); } } -- cgit v1.2.3