summaryrefslogtreecommitdiff
path: root/libgps_json.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2018-10-29 16:52:46 -0700
committerGary E. Miller <gem@rellim.com>2018-10-29 16:52:46 -0700
commit751201571b0a152f9727a70ca349a2290f0b9e3d (patch)
tree8975f7f0e5a56ce2ae27d56747f5c58476d4d33c /libgps_json.c
parentf4a541357a7b9df4168a4c8f931ffddf7a525f44 (diff)
downloadgpsd-751201571b0a152f9727a70ca349a2290f0b9e3d.tar.gz
rawdata_t: Split mtime into time and nsec.
And have to use t_real for mtime bacause json.c has no t_long type.
Diffstat (limited to 'libgps_json.c')
-rw-r--r--libgps_json.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libgps_json.c b/libgps_json.c
index d1abdcd6..dbe51fe4 100644
--- a/libgps_json.c
+++ b/libgps_json.c
@@ -137,6 +137,8 @@ static int json_raw_read(const char *buf, struct gps_data_t *gpsdata,
const char **endptr)
{
int measurements;
+ double mtime_s, mtime_ns;
+
const struct json_attr_t json_attrs_meas[] = {
/* *INDENT-OFF* */
{"gnssid", t_short, STRUCTOBJECT(struct meas_t, gnssid)},
@@ -153,10 +155,10 @@ static int json_raw_read(const char *buf, struct gps_data_t *gpsdata,
{"class", t_check, .dflt.check = "RAW"},
{"device", t_string, .addr.string = gpsdata->dev.path,
.len = sizeof(gpsdata->dev.path)},
- {"time", t_time, .addr.real = &gpsdata->skyview_time,
- .dflt.real = NAN},
- {"time", t_real, .addr.real = &gpsdata->skyview_time,
- .dflt.real = NAN},
+ {"time", t_real, .addr.real = &mtime_s,
+ .dflt.real = NAN},
+ {"nsec", t_real, .addr.real = &mtime_ns,
+ .dflt.real = NAN},
{"meas", t_array,
STRUCTARRAY(gpsdata->raw.meas,
json_attrs_meas, &measurements)},
@@ -170,6 +172,10 @@ static int json_raw_read(const char *buf, struct gps_data_t *gpsdata,
status = json_read_object(buf, json_attrs_raw, endptr);
if (status != 0)
return status;
+ if (0 == isfinite(mtime_s) || 0 == isfinite(mtime_ns))
+ return status;
+ gpsdata->raw.mtime.tv_sec = (time_t)mtime_s;
+ gpsdata->raw.mtime.tv_nsec = (long)mtime_ns;
return 0;
}