diff options
author | Gary E. Miller <gem@rellim.com> | 2015-02-02 17:28:22 -0800 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2015-02-02 17:28:22 -0800 |
commit | 507d3da94068fe89019a80839394faffad30ad1a (patch) | |
tree | 04ed11d0347f1fb2517d3460b5e1abc3414ae536 /monitor_sirf.c | |
parent | f488a78cfdb00a36c7aeef2ff5f25cc54f4d27a0 (diff) | |
download | gpsd-507d3da94068fe89019a80839394faffad30ad1a.tar.gz |
Fix SiRF PPS offset precision in gpsmon
Diffstat (limited to 'monitor_sirf.c')
-rw-r--r-- | monitor_sirf.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/monitor_sirf.c b/monitor_sirf.c index 6a2303ac..bee0dfad 100644 --- a/monitor_sirf.c +++ b/monitor_sirf.c @@ -590,9 +590,18 @@ static void sirf_update(void) /*@-compdef@*/ /*@-type@*/ /* splint is confused about struct timespec */ if (pps_thread_lastpps(&session, &drift) > 0) { - /* WARNING! this will fail if timedelta more than a few seconds */ - double timedelta = timespec_diff_ns(drift.real, drift.clock) * 1e-9; - display(mid7win, 2, 39, "%.9f", timedelta); /* PPS offset */ + /* NOTE: can not use double here due to precision requirements */ + struct timespec timedelta; + TS_SUB( &timedelta, &drift.real, &drift.clock); + if ( 86400 < (long)timedelta.tv_sec ) { + /* more than one day off, overflow */ + /* need a bigger field to show it */ + (void)mvwprintw(mid7win, 2, 39, "> 1 day"); + } else { + (void)mvwprintw(mid7win, 4, 39, "%ld.09ld", + (long)timedelta.tv_sec, + (long)timedelta.tv_nsec); + } (void)wnoutrefresh(mid7win); } /*@+type@*/ |