aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2012-03-12 23:37:21 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2012-03-12 23:37:21 +0000
commit267d9a07255d96a564da64ce5c819ebc4701d5f1 (patch)
tree0fa84ee59a7e3a9ad53ae15780f7e80c40a75c1b /src
parent577e2f84f58a2f46839e82b096cf9493d2ef035b (diff)
downloadverteco-267d9a07255d96a564da64ce5c819ebc4701d5f1.tar.gz
Force log upon startup
Diffstat (limited to '')
-rw-r--r--src/modbuslog.c10
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);
}
}