summaryrefslogtreecommitdiff
path: root/gpsmon.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-11-02 16:02:05 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-11-02 16:02:05 -0400
commit76508d80374ffaa85ac4a62f04272c61a2cb2d13 (patch)
tree2560b94088cca8533994ccf74f3eb583aaf47005 /gpsmon.c
parentfa7fd7a281bcbec1a75fe783c9bc10bf7c94bf9c (diff)
downloadgpsd-76508d80374ffaa85ac4a62f04272c61a2cb2d13.tar.gz
Pretty up the PPS display in gpmon.
The idea is to make PPS visually obvious in the packed buffer. Time display should be on the monitor panel with the other derived data. The UBX monitor provides an example of how to do this.
Diffstat (limited to 'gpsmon.c')
-rw-r--r--gpsmon.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/gpsmon.c b/gpsmon.c
index b9e6230a..f90cf934 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -45,6 +45,7 @@ extern struct monitor_object_t oncore_mmt, tnt_mmt, aivdm_mmt;
struct gps_device_t session;
WINDOW *devicewin;
bool serial;
+float timedelta = 0;
/* These are private */
static struct gps_context_t context;
@@ -836,16 +837,22 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
/*@+observertrans +nullpass +globstate@*/
#ifdef PPS_ENABLE
-/* The PPS thread_report_hook callback. This or a pps_hook callback is
- * needed to keep the PPS thread running.
- */
static char *pps_report(struct gps_device_t *session UNUSED,
- struct timeval *actual_tv,
- struct timespec *ts,
- double edge_offset) {
- packet_log("PPS time=%llu.%09lu; clock=%llu.%09lu; edge_offset=%.9f\n",
- (long long)actual_tv->tv_sec, actual_tv->tv_usec * 1000,
- (long long)ts->tv_sec, ts->tv_nsec, edge_offset);
+ struct timeval *pps_tv,
+ struct timespec *sysclock_ts,
+ double edge_offset UNUSED) {
+ /*
+ * Ugh. Access through a shared global is nasty.
+ * This may be a layer violation that needs to be fixed.
+ *
+ * Read access to timedelta is not thread-locked.
+ * Instead we're relying on access to floats to be atomic.
+ */
+ timedelta = (pps_tv->tv_sec + pps_tv->tv_usec / 1e6)
+ - (sysclock_ts->tv_sec + sysclock_ts->tv_nsec / 1e9);
+ packet_log("-------------------------------------"
+ " PPS "
+ "-------------------------------------\n");
return "gpsmon";
}
#endif /* PPS_ENABLE */