bearing / dosenet-raspberrypi

Raspberry Pi specific software for dosimeters.
MIT License
7 stars 21 forks source link

Confirm NTP update before running `dosenet.sh` #42

Closed bplimley closed 8 years ago

bplimley commented 8 years ago

When the pi is powered off, the CPU clock does not run. That means when it powers back on, the system time is incorrect, until it updates from the internet. This happens through the NTP protocol in the system (see man ntp and man ntpd).

Currently, the system time gets updated through ntpd typically sometime after dosenet.sh runs. This means that the system time update via ntpd throws off the time intervals that Manager is tracking. (This is handled reasonably now as of #34).

With issue #12 and the pi using its own timestamp on the data packets, however, the time stamp must be accurate from the beginning. Therefore, the dosenet.sh shell script should check whether NTP has updated the system time, and wait for that before running python manager.py ....

bplimley commented 8 years ago

So unfortunately, this isn't working... ntp-wait doesn't seem to work inside dosenet.sh even though it works outside of it.

To check (immediately after booting):

grep dosenet /var/log/messages

(you see that Waiting for NTP to be synced... and Starting DoseNet script happen very close to each other)

date; ntp-wait -v; date

(you see that ntp-wait is waiting. On my device it generally takes 15 minutes for NTP to sync.)