summaryrefslogtreecommitdiff
path: root/gpsmon.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-11-17 08:47:16 -0500
committerEric S. Raymond <esr@thyrsus.com>2013-11-17 08:47:16 -0500
commita7c3cf50d4533fd1d01be4dffcdaaffb9a9d1ac8 (patch)
tree2f7cfbfe79785ca2fea7df433da3e57547cf3562 /gpsmon.c
parentb9732abae7857c5873eec7fbd96924c2403e4a0f (diff)
downloadgpsd-a7c3cf50d4533fd1d01be4dffcdaaffb9a9d1ac8.tar.gz
PPs drift is now visible in client-mode JSON...
...but seems to be stuck on zero. Must figure that out.
Diffstat (limited to 'gpsmon.c')
-rw-r--r--gpsmon.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/gpsmon.c b/gpsmon.c
index cce87086..27fb44f2 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -147,6 +147,10 @@ static inline void report_lock(void) { }
static inline void report_unlock(void) { }
#endif /* PPS_ENABLE */
+#define PPSBAR "-------------------------------------" \
+ " PPS " \
+ "-------------------------------------\n"
+
/******************************************************************************
*
* Visualization helpers
@@ -665,10 +669,31 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
{
char buf[BUFSIZ];
- (void)snprintf(buf, sizeof(buf), "(%d) ", (int)device->packet.outbuflen);
- cond_hexdump(buf + strlen(buf), sizeof(buf) - strlen(buf),
- (char *)device->packet.outbuffer, device->packet.outbuflen);
- (void)strlcat(buf, "\n", sizeof(buf) - strlen(buf));
+ if (!serial && strncmp((char*)device->packet.outbuffer, "{\"class\":\"PPS\",", 13) == 0)
+ {
+ const char *end;
+ struct gps_data_t noclobber;
+ int status = json_pps_read((const char *)device->packet.outbuffer,
+ &noclobber,
+ &end);
+ if (status != 0) {
+ /* FIXME: figure out why using json_error_string() core dumps */
+ complain("Ill-formed PPS packet: %d", status);
+ buf[0] = '\0';
+ } else {
+ (void)strlcpy(buf, PPSBAR, BUFSIZ);
+ session.gpsdata.timedrift = noclobber.timedrift;
+ session.ppscount++;
+ }
+ }
+ else
+ {
+ (void)snprintf(buf, sizeof(buf), "(%d) ",
+ (int)device->packet.outbuflen);
+ cond_hexdump(buf + strlen(buf), sizeof(buf) - strlen(buf),
+ (char *)device->packet.outbuffer,device->packet.outbuflen);
+ (void)strlcat(buf, "\n", sizeof(buf) - strlen(buf));
+ }
if (curses_active)
select_packet_monitor(device);
@@ -966,9 +991,7 @@ static bool do_command(const char *line)
#ifdef PPS_ENABLE
static /*@observer@*/ char *pps_report(struct gps_device_t *session UNUSED,
struct timedrift_t *td UNUSED) {
- packet_log("#------------------------------------"
- " PPS "
- "------------------------------------#\n");
+ packet_log(PPSBAR);
return "gpsmon";
}
#endif /* PPS_ENABLE */