diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2015-03-09 04:32:04 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-03-09 04:32:04 -0400 |
commit | 83b22b895bf456bcf82808f112d50c03e7c54c3c (patch) | |
tree | ac6950de9b7e81364433cecf9082f3930376a0c3 /gpsd_json.c | |
parent | 1a207b65f57adeb628761c56c9a0cf5e55193c91 (diff) | |
download | gpsd-83b22b895bf456bcf82808f112d50c03e7c54c3c.tar.gz |
Using clock_gettime() for TIMING is more accurate and lets use remove a float.
All regression tests pass.
Diffstat (limited to 'gpsd_json.c')
-rw-r--r-- | gpsd_json.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/gpsd_json.c b/gpsd_json.c index db478dbf..3aeb55f2 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -184,12 +184,15 @@ void json_tpv_dump(const struct gps_device_t *session, str_appendf(reply, replylen, "\"epc\":%.2f,", gpsdata->fix.epc); #ifdef TIMING_ENABLE if (policy->timing) { + char rtime_str[TIMESPEC_LEN]; + struct timespec rtime_tmp; + clock_gettime(CLOCK_REALTIME, &rtime_tmp); + timespec_str(&rtime_tmp, rtime_str, sizeof(rtime_str)); + str_appendf(reply, replylen, "\"rtime\":%s,", rtime_str); #ifdef PPS_ENABLE /*@-type -formattype@*/ /* splint is confused about struct timespec */ if (session->ppscount) { - char ts_str[TIMESPEC_LEN]; /* buffer to hold printable timespec */ - /* you can not use a double here as you will lose 11 bits - * of precision */ + char ts_str[TIMESPEC_LEN]; struct timespec clock_tmp = session->ppslast.clock; timespec_str( &clock_tmp, ts_str, sizeof(ts_str) ); str_appendf(reply, replylen, "\"pps\":%s,", ts_str); @@ -197,14 +200,14 @@ void json_tpv_dump(const struct gps_device_t *session, /*@+type +formattype@*/ #endif /* PPS_ENABLE */ str_appendf(reply, replylen, - "\"sor\":%.9f,\"chars\":%lu,\"sats\":%2d,\"rtime\":%.9f,\"week\":%u,\"tow\":%.3f,\"rollovers\":%d", - session->sor, - session->chars, - gpsdata->satellites_used, - rtime, - session->context->gps_week, - session->context->gps_tow, - session->context->rollovers); + "\"sor\":%.9f,\"chars\":%lu,\"sats\":%2d," + "\"week\":%u,\"tow\":%.3f,\"rollovers\":%d", + session->sor, + session->chars, + gpsdata->satellites_used, + session->context->gps_week, + session->context->gps_tow, + session->context->rollovers); } #endif /* TIMING_ENABLE */ } |