I suspect that the occasional data loss when transmitting lots of
data points is caused by buggy firmware which drops packets sent
too quickly.
-static void interruptible_sleep(int seconds)
+static void interruptible_msleep(int ms)
{
sigprocmask(SIG_UNBLOCK, &term_sigs, NULL);
{
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);
}
sigprocmask(SIG_BLOCK, &term_sigs, NULL);
}
inited = 1;
log_error("Data logger not connected, waiting until it appears");
}
inited = 1;
log_error("Data logger not connected, waiting until it appears");
}
- interruptible_sleep(30);
+ interruptible_msleep(30000);
continue;
}
log_info("Listening");
continue;
}
log_info("Listening");
if (err > 0 && parse_packet(reply))
want_sleep = 0;
if (want_sleep) {
if (err > 0 && parse_packet(reply))
want_sleep = 0;
if (want_sleep) {
- interruptible_sleep(4);
+ interruptible_msleep(4000);
+ } else
+ interruptible_msleep(5);
}
log_info("Disconnecting data logger");
release_device();
inited = 0;
}
log_info("Disconnecting data logger");
release_device();
inited = 0;
- interruptible_sleep(10);
+ interruptible_msleep(10000);
}
log_info("Terminated");
}
log_info("Terminated");