summaryrefslogtreecommitdiff
path: root/libgps_json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-03-10 14:55:09 -0500
committerEric S. Raymond <esr@thyrsus.com>2011-03-10 14:55:09 -0500
commit947c427e3691fb4bd2c49585e7478198c9481219 (patch)
treed9d46314d1c090e0415ff48b441f5054acab2b10 /libgps_json.c
parent736379fc0411971e4f2aa3e8d048ab1205dbcc76 (diff)
downloadgpsd-947c427e3691fb4bd2c49585e7478198c9481219.tar.gz
Library time parsing is now backward-compatible with 2.95.
Diffstat (limited to 'libgps_json.c')
-rw-r--r--libgps_json.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/libgps_json.c b/libgps_json.c
index bd22565a..06b537e0 100644
--- a/libgps_json.c
+++ b/libgps_json.c
@@ -45,6 +45,8 @@ static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata,
.len = sizeof(gpsdata->tag)},
{"time", t_string, .addr.string = tbuf,
.len = sizeof(tbuf)},
+ {"time", t_real, .addr.real = &gpsdata->fix.time,
+ .dflt.real = NAN},
{"ept", t_real, .addr.real = &gpsdata->fix.ept,
.dflt.real = NAN},
{"lon", t_real, .addr.real = &gpsdata->fix.longitude,
@@ -84,10 +86,12 @@ static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata,
gpsdata->status = STATUS_FIX;
gpsdata->set = STATUS_SET;
/*@-usedef@*/
- if (tbuf[0] == '\0')
- gpsdata->fix.time = NAN;
- else
- gpsdata->fix.time = iso8601_to_unix(tbuf);
+ if (isnan(gpsdata->fix.time)!=0) {
+ if (tbuf[0] == '\0')
+ gpsdata->fix.time = NAN;
+ else
+ gpsdata->fix.time = iso8601_to_unix(tbuf);
+ }
/*@+usedef@*/
if (isnan(gpsdata->fix.time) == 0)
gpsdata->set |= TIME_SET;
@@ -136,6 +140,8 @@ static int json_noise_read(const char *buf, struct gps_data_t *gpsdata,
.len = sizeof(gpsdata->tag)},
{"time", t_string, .addr.string = tbuf,
.len = sizeof(tbuf)},
+ {"time", t_real, .addr.real = &gpsdata->gst.utctime,
+ .dflt.real = NAN},
{"rms", t_real, .addr.real = &gpsdata->gst.rms_deviation,
.dflt.real = NAN},
{"major", t_real, .addr.real = &gpsdata->gst.smajor_deviation,
@@ -160,10 +166,12 @@ static int json_noise_read(const char *buf, struct gps_data_t *gpsdata,
return status;
/*@-usedef@*/
- if (tbuf[0] == '\0')
- gpsdata->gst.utctime = NAN;
- else
- gpsdata->gst.utctime = iso8601_to_unix(tbuf);
+ if (isnan(gpsdata->fix.time)!=0) {
+ if (tbuf[0] == '\0')
+ gpsdata->gst.utctime = NAN;
+ else
+ gpsdata->gst.utctime = iso8601_to_unix(tbuf);
+ }
/*@+usedef@*/
gpsdata->set |= GST_SET;
@@ -195,6 +203,8 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata,
.len = sizeof(gpsdata->tag)},
{"time", t_string, .addr.string = tbuf,
.len = sizeof(tbuf)},
+ {"time", t_real, .addr.real = &gpsdata->fix.time,
+ .dflt.real = NAN},
{"hdop", t_real, .addr.real = &gpsdata->dop.hdop,
.dflt.real = NAN},
{"xdop", t_real, .addr.real = &gpsdata->dop.xdop,
@@ -228,12 +238,14 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata,
if (status != 0)
return status;
- /*@-usedef@*/
+ /*@-usedef@*/
+ if (isnan(gpsdata->fix.time)!=0) {
if (tbuf[0] == '\0')
gpsdata->skyview_time = NAN;
else
gpsdata->skyview_time = iso8601_to_unix(tbuf);
- /*@+usedef@*/
+ }
+ /*@+usedef@*/
gpsdata->satellites_used = 0;
gpsdata->satellites_visible = 0;
(void)memset(gpsdata->used, '\0', sizeof(gpsdata->used));