From f234f7725398b62cf6fad8a11fb7f23d32e04f1b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 29 Mar 2016 08:44:39 -0400 Subject: Fix JSON dump code to not report time in GST unless there's a valid fix. --- gpsd_json.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gpsd_json.c') diff --git a/gpsd_json.c b/gpsd_json.c index 44b2c0e7..17c31030 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -216,15 +216,16 @@ void json_tpv_dump(const struct gps_device_t *session, void json_noise_dump(const struct gps_data_t *gpsdata, char *reply, size_t replylen) { - char tbuf[JSON_DATE_MAX+1]; - assert(replylen > sizeof(char *)); (void)strlcpy(reply, "{\"class\":\"GST\",", replylen); if (gpsdata->dev.path[0] != '\0') str_appendf(reply, replylen, "\"device\":\"%s\",", gpsdata->dev.path); + if (isnan(gpsdata->fix.time) == 0) { + char tbuf[JSON_DATE_MAX+1]; str_appendf(reply, replylen, "\"time\":\"%s\",", unix_to_iso8601(gpsdata->gst.utctime, tbuf, sizeof(tbuf))); + } #define ADD_GST_FIELD(tag, field) do { \ if (isnan(gpsdata->gst.field) == 0) \ str_appendf(reply, replylen, "\"" tag "\":%.3f,", gpsdata->gst.field); \ -- cgit v1.2.1