diff options
Diffstat (limited to '')
-rw-r--r-- | src/modbuslog.c | 10 |
1 files 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); } } |