UMONS-GFA / ardas

FM Sensors conditionning based on on Arduino
GNU General Public License v3.0
0 stars 1 forks source link

Set raspberry clock from ardas RTC if NTP server is not available when starting raspardas #73

Open kaufmanno opened 7 years ago

kaufmanno commented 6 years ago

The main problem with the current implementation occurs when the raspberry has lost track of time and has no access to NTP (i.e. a raspberry pi after a lightning strike: power outage + fried switch). The hardware clock would be incorrectly set at reboot and even if the RTC of the ArDAS is still correctely set and thus recorded data are stored with the correct time, date and time in logs and log names would be wrong.

->Check if this approach works?

import subprocess
import shlex

subprocess.call(shlex.split("timedatectl set-ntp false"))  # May be necessary
subprocess.call(shlex.split("sudo date -s '2 OCT 2006 18:00:00'"))
subprocess.call(shlex.split("sudo hwclock -w"))
subprocess.call(shlex.split("timedatectl set-ntp true"))  # May be necessary