Thomas Keffer <[email protected]> writes:

> Do you have a real-time clock?

No.  I knew I should, and had thought I had avoided the problems and
forgot about the issue.  Or rather I think I have one someplace that I
haven't installed yet :-)

I just checked and added some instrumentation.

First, when NetBSD boots, it grabs the time from the filesystem, so the
time is behind, but definitely not 1970.  Startup is not parallelized,
so things after ntpdate should have the right time.

A recent reboot looked like

Mar  9 13:20:32 wx ntpdate[276]: Can't find host 0.netbsd.pool.ntp.org: 
hostname nor servname provided, or not known (8)
Mar  9 13:23:53 wx ntpdate[276]: step time server 204.9.54.119 offset 
173.216131 sec

(not sure about that DNS, but other things were found).

weewx is not started until ntpdate has run and ntpd is started.   So
normally, weewx does not encounter bad times.

However, I suspect that on restoration of power, there were some other
issues in my network which caused the weewx RPI3 to not get an IP
address, and thus ntpdate to time out, and therefore weewx to start with
time that is based on the crash time.  So probably still ahead of the
last time it ran, but sort of a few minutes into the failure, not the
restoration time plus a bit like it should be.

So, I wonder if weewx was changing the Davis console clock, based on the
computer being 1.25h slow.

To avoid this in the future, I wrote a script to delay weewx start until
ntpd is happy.  On a reboot of the RPI with everything else stably
powered, this resulted in a delay of 3m20s.  The time was already ok
(from ntpdate), but that's not reliable.  (I think the script depends
only on ntpd/etc. and things specified by POSIX.)

I wonder about weewx being able to check ntp sync, and only being
willing to adjust the console if ntp reports that it is synced.   In a
way the console is a RTC.

Thanks again for paying attention to my question.


#!/bin/sh

date
ntpq -c sysinfo
ntpq -pn

while sleep 5; do
    trace=`ntptrace -n | head -1`
    stratum=`echo $trace | sed -e 's/.*stratum \([0-9]*\),.*/\1/'`
    if [ "$stratum" -lt 16 ]; then
        echo OK $trace
        break;
    fi
    echo UNSYNC $trace
done

date
ntpq -c sysinfo
ntpq -pn

bin/weewxd weewx.conf

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to