summaryrefslogtreecommitdiff
path: root/gpsd_json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-09-20 22:52:57 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-09-20 22:52:57 -0400
commita6f1d32121b7ce8b4cb9485f238eb62f23b75c7e (patch)
tree5fba20ea0ee790ac3b9373a237856c89bf4f9152 /gpsd_json.c
parente9034a445991b1fdceb6d536f5415b320c049e6a (diff)
downloadgpsd-a6f1d32121b7ce8b4cb9485f238eb62f23b75c7e.tar.gz
Remove the old latency-profiling machinery.
It hasn't actually worked since we switched protocols to JSON. This diff puts the framework in place for new machinery using timing attributes in the TPV sentence.
Diffstat (limited to 'gpsd_json.c')
-rw-r--r--gpsd_json.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/gpsd_json.c b/gpsd_json.c
index bcaa0e3c..bb5a6201 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -113,10 +113,14 @@ void json_version_dump( /*@out@*/ char *reply, size_t replylen)
GPSD_PROTO_MAJOR_VERSION, GPSD_PROTO_MINOR_VERSION);
}
-void json_tpv_dump(const struct gps_data_t *gpsdata,
+void json_tpv_dump(const struct gps_data_t *gpsdata,
+ const struct policy_t *policy,
/*@out@*/ char *reply, size_t replylen)
{
char tbuf[JSON_DATE_MAX+1];
+#ifdef TIMING_ENABLE
+ timestamp_t xmit_time = realtimestamp();
+#endif /* TIMING_ENABLE */
assert(replylen > 2);
(void)strlcpy(reply, "{\"class\":\"TPV\",", replylen);
@@ -199,6 +203,13 @@ void json_tpv_dump(const struct gps_data_t *gpsdata,
(void)snprintf(reply + strlen(reply),
replylen - strlen(reply),
"\"epc\":%.2f,", gpsdata->fix.epc);
+#ifdef TIMING_ENABLE
+ if (policy->timing)
+ (void)snprintf(reply + strlen(reply),
+ replylen - strlen(reply),
+ "\"xmit_time\":%f,",
+ xmit_time);
+#endif /* TIMING_ENABLE */
}
if (reply[strlen(reply) - 1] == ',')
reply[strlen(reply) - 1] = '\0'; /* trim trailing comma */
@@ -2922,7 +2933,7 @@ void json_data_report(gps_mask_t changed,
buf[0] = '\0';
if ((changed & REPORT_IS) != 0) {
- json_tpv_dump(datap, buf+strlen(buf), buflen-strlen(buf));
+ json_tpv_dump(datap, policy, buf+strlen(buf), buflen-strlen(buf));
}
if ((changed & GST_SET) != 0) {