[OpenWrt-Devel] ugps notes

Paul Fertser fercerpav at gmail.com
Sun Aug 10 02:44:11 EDT 2014


A couple of notes about your ugps NMEA daemon.

1. The usual common way to perform timezone conversion is to putenv()
TZ variable (empty if you want UTC) and call tzset(). Then it becomes
the current timezone for the process and you can do mktime() after
filling the struct with the UTC (hopefully, see next note) components
you get from the receiver. Of course, this is not thread-safe. The way
you currently use "daylight" global variable is broken, as it doesn't
indicate if DST should be applied to the time you got from GPS (it
even doesn't indicate if DST should be applied to the current system
time, just that the current timezone has DST during some part of the

2. Even if the receiver has a valid 3D-fix ("A"), it still can emit
wrong time for arbitrary long. The reason for this is that NMEA
designers did the wrong thing and decided the protocol should include
only UTC time disregarding the fact that a GPS receiver is guaranteed
to have only TAI. To convert to UTC it needs to take into account the
current amount of leap seconds which is transferred once every 12.5
minutes (and you need to have good signal level at that time, here
good means "better than actually required for keeping the fix", so
it's possible you get a proper fix but then the signal conditions
changed, you still have the fix but can't learn the leap seconds
offset). Some receivers I saw were just silently using the quantity
effective during their build time, and then after finally learning the
correct value, the time jumped by 1 or 2 seconds. There's no proper
way to workaround this apart from comparing with an external
timesource. If there's nothing to compare with, you should probably at
least believe the latest time as reported with NMEA (even if it
differs by a single second from the current time); 

3. s/elivation/elevation/g

Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:fercerpav at gmail.com
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list