From 507d3da94068fe89019a80839394faffad30ad1a Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Mon, 2 Feb 2015 17:28:22 -0800 Subject: Fix SiRF PPS offset precision in gpsmon --- monitor_oncore.c | 2 ++ monitor_sirf.c | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/monitor_oncore.c b/monitor_oncore.c index ac192db7..c763b399 100644 --- a/monitor_oncore.c +++ b/monitor_oncore.c @@ -397,6 +397,8 @@ static void oncore_update(void) { double pps_offset; + /* note this is the GPS calc'ed offset + * not a PPS offset gpsmon calculated */ pps_offset = (double)getbes32(buf, 4) / 1000000.0; (void)mvwprintw(Aywin, 2, 2, " %7.3f ms", pps_offset); 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@*/ -- cgit v1.2.1