diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2015-02-23 14:40:31 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-02-23 14:40:31 -0500 |
commit | da96a95a9a85299b228dacbe345c5499736d36dc (patch) | |
tree | a2e421462548c91edc833e095d53725f8840195e /libgps_json.c | |
parent | 0747ffe258042efe53c10964c579af62c7b8ae30 (diff) | |
download | gpsd-da96a95a9a85299b228dacbe345c5499736d36dc.tar.gz |
TOFF JSON message implemented and documented.
All regression tests pass. PPS observed live with gosmon.
gpsmon presently ignores this message, but shout display its contents near PPS.
Diffstat (limited to 'libgps_json.c')
-rw-r--r-- | libgps_json.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libgps_json.c b/libgps_json.c index c9a35363..ba967ca8 100644 --- a/libgps_json.c +++ b/libgps_json.c @@ -346,6 +346,46 @@ static int json_error_read(const char *buf, struct gps_data_t *gpsdata, return status; } +int json_toff_read(const char *buf, struct gps_data_t *gpsdata, + /*@null@*/ const char **endptr) +{ + int real_sec = 0, real_nsec = 0, clock_sec = 0, clock_nsec = 0; + /*@ -fullinitblock @*/ + const struct json_attr_t json_attrs_toff[] = { + /* *INDENT-OFF* */ + {"class", t_check, .dflt.check = "TOFF"}, + {"device", t_string, .addr.string = gpsdata->dev.path, + .len = sizeof(gpsdata->dev.path)}, + {"real_sec", t_integer, .addr.integer = &real_sec, + .dflt.integer = 0}, + {"real_nsec", t_integer, .addr.integer = &real_nsec, + .dflt.integer = 0}, + {"clock_sec", t_integer, .addr.integer = &clock_sec, + .dflt.integer = 0}, + {"clock_nsec",t_integer, .addr.integer = &clock_nsec, + .dflt.integer = 0}, + {NULL}, + /* *INDENT-ON* */ + }; + /*@ +fullinitblock @*/ + int status; + + memset(&gpsdata->toff, '\0', sizeof(gpsdata->toff)); + status = json_read_object(buf, json_attrs_toff, endptr); + /*@-usedef@*/ + /*@-type@*//* splint is confused about struct timespec */ + gpsdata->toff.real.tv_sec = (time_t)real_sec; + gpsdata->toff.real.tv_nsec = (long)real_nsec; + gpsdata->toff.clock.tv_sec = (time_t)clock_sec; + gpsdata->toff.clock.tv_nsec = (long)clock_nsec; + /*@+type@*/ + /*@+usedef@*/ + if (status != 0) + return status; + + return status; +} + int json_pps_read(const char *buf, struct gps_data_t *gpsdata, /*@null@*/ const char **endptr) { @@ -517,6 +557,13 @@ int libgps_json_unpack(const char *buf, gpsdata->set |= ERROR_SET; } return status; + } else if (str_starts_with(classtag, "\"class\":\"TOFF\"")) { + status = json_pps_read(buf, gpsdata, end); + if (status == 0) { + gpsdata->set &= ~UNION_SET; + gpsdata->set |= TOFF_SET; + } + return status; } else if (str_starts_with(classtag, "\"class\":\"PPS\"")) { status = json_pps_read(buf, gpsdata, end); if (status == 0) { |