summaryrefslogtreecommitdiff
path: root/libgps_json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-01-29 08:24:30 -0500
committerEric S. Raymond <esr@thyrsus.com>2011-01-29 08:24:30 -0500
commit34e440c26892b2950d7a368974bbbf59fdf59883 (patch)
tree130a34a5942111b62415d16c8dbe420cecbf2926 /libgps_json.c
parent50ac32cd433dd8c4a3da702edea4765694315492 (diff)
downloadgpsd-34e440c26892b2950d7a368974bbbf59fdf59883.tar.gz
Timestamps in TPV and SKY go from float seconds since Unix epoch to ISO8601.
Protocol version number is bumped. Python and C test clients are known to work; interfaces of the C and Python client bindings are unchanged. Third-party client-side bindings which rely on naively copying JSON members will break (implementers have been repeatedly warned not to do this).
Diffstat (limited to 'libgps_json.c')
-rw-r--r--libgps_json.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/libgps_json.c b/libgps_json.c
index bc33b4b9..b2ea1a59 100644
--- a/libgps_json.c
+++ b/libgps_json.c
@@ -34,6 +34,7 @@ static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata,
/*@null@*/ const char **endptr)
{
int status;
+ char tbuf[JSON_DATE_MAX];
/*@ -fullinitblock @*/
const struct json_attr_t json_attrs_1[] = {
/* *INDENT-OFF* */
@@ -42,8 +43,8 @@ static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata,
.len = sizeof(gpsdata->dev.path)},
{"tag", t_string, .addr.string = gpsdata->tag,
.len = sizeof(gpsdata->tag)},
- {"time", t_real, .addr.real = &gpsdata->fix.time,
- .dflt.real = NAN},
+ {"time", t_string, .addr.string = tbuf,
+ .len = sizeof(tbuf)},
{"ept", t_real, .addr.real = &gpsdata->fix.ept,
.dflt.real = NAN},
{"lon", t_real, .addr.real = &gpsdata->fix.longitude,
@@ -82,6 +83,12 @@ static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata,
if (status == 0) {
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);
+ /*@+usedef@*/
if (isnan(gpsdata->fix.time) == 0)
gpsdata->set |= TIME_SET;
if (isnan(gpsdata->fix.ept) == 0)
@@ -118,6 +125,7 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata,
/*@null@*/ const char **endptr)
{
bool usedflags[MAXCHANNELS];
+ char tbuf[JSON_DATE_MAX];
/*@ -fullinitblock @*/
const struct json_attr_t json_attrs_2_1[] = {
/* *INDENT-OFF* */
@@ -136,8 +144,8 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata,
.len = sizeof(gpsdata->dev.path)},
{"tag", t_string, .addr.string = gpsdata->tag,
.len = sizeof(gpsdata->tag)},
- {"time", t_real, .addr.real = &gpsdata->fix.time,
- .nodefault = true},
+ {"time", t_string, .addr.string = tbuf,
+ .len = sizeof(tbuf)},
{"hdop", t_real, .addr.real = &gpsdata->dop.hdop,
.dflt.real = NAN},
{"xdop", t_real, .addr.real = &gpsdata->dop.xdop,
@@ -169,6 +177,12 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata,
if (status != 0)
return status;
+ /*@-usedef@*/
+ if (tbuf[0] == '\0')
+ gpsdata->skyview_time = NAN;
+ else
+ gpsdata->skyview_time = iso8601_to_unix(tbuf);
+ /*@+usedef@*/
gpsdata->satellites_used = 0;
for (i = j = 0; i < MAXCHANNELS; i++) {
if (usedflags[i]) {