summaryrefslogtreecommitdiff
path: root/gpsd_json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2016-03-29 08:44:39 -0400
committerEric S. Raymond <esr@thyrsus.com>2016-03-29 08:46:13 -0400
commitf234f7725398b62cf6fad8a11fb7f23d32e04f1b (patch)
treed1a47a7007aa14100cc81f3617f9cd72a0d401b6 /gpsd_json.c
parent07ba9b5518c405ac1d2503181c57501d15cf1e57 (diff)
downloadgpsd-f234f7725398b62cf6fad8a11fb7f23d32e04f1b.tar.gz
Fix JSON dump code to not report time in GST unless there's a valid fix.
Diffstat (limited to 'gpsd_json.c')
-rw-r--r--gpsd_json.c5
1 files changed, 3 insertions, 2 deletions
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); \