case 10415:
*name = "ursarium";
return val - 0.93;
+ case 10707:
+ *name = "balcony";
+ return val - 0.71;
case 19246:
*name = "catarium";
return val + 0.49;
/*** Main ***/
+static sigset_t term_sigs;
static volatile sig_atomic_t want_shutdown;
static void sigterm_handler(int sig __attribute__((unused)))
want_shutdown = 1;
}
+static void interruptible_msleep(int ms)
+{
+ sigprocmask(SIG_UNBLOCK, &term_sigs, NULL);
+ struct timespec ts = { .tv_sec = ms/1000, .tv_nsec = (ms%1000) * 1000000 };
+ nanosleep(&ts, NULL);
+ sigprocmask(SIG_BLOCK, &term_sigs, NULL);
+}
+
static const struct option long_options[] = {
{ "debug", 0, NULL, 'd' },
{ "log-dir", 1, NULL, 'l' },
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
- sigset_t term_sigs;
sigemptyset(&term_sigs);
sigaddset(&term_sigs, SIGTERM);
sigaddset(&term_sigs, SIGINT);
inited = 1;
log_error("Data logger not connected, waiting until it appears");
}
- sleep(30);
+ interruptible_msleep(30000);
continue;
}
log_info("Listening");
want_sleep = 1;
if (err > 0 && parse_packet(reply))
want_sleep = 0;
- sigprocmask(SIG_UNBLOCK, &term_sigs, NULL);
if (want_sleep) {
- sleep(4);
+ interruptible_msleep(4000);
want_stats = 1;
- }
- sigprocmask(SIG_BLOCK, &term_sigs, NULL);
+ } else
+ interruptible_msleep(5);
}
log_info("Disconnecting data logger");
release_device();
inited = 0;
+ interruptible_msleep(10000);
}
log_info("Terminated");