summaryrefslogtreecommitdiff
path: root/gpsd_json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-08-25 13:03:45 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-08-25 13:03:45 +0000
commit9be0d591715b8d48ae59addaa4cdea25f35921b0 (patch)
tree0ab33c097e0ad618092890f4d857117a6644b906 /gpsd_json.c
parent536093cb652815046794e73977622236739de4b6 (diff)
downloadgpsd-9be0d591715b8d48ae59addaa4cdea25f35921b0.tar.gz
Add character type to JSON parser.
Make gpsctl work with new protocol (only the device ID function is tested at this point).
Diffstat (limited to 'gpsd_json.c')
-rw-r--r--gpsd_json.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/gpsd_json.c b/gpsd_json.c
index 0cdb8da4..2e8ddfa7 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -189,14 +189,23 @@ void json_device_dump(struct gps_device_t *device,
(void)strlcat(reply, "\",", replylen);
}
if (device->subtype[0] != '\0') {
- (void)strlcat(reply, "\"subtype\":\"", replylen);
+ (void)strlcat(reply, "\"subtype\":\",", replylen);
(void)strlcat(reply,
device->subtype,
replylen);
(void)strlcat(reply, "\",", replylen);
}
- if (reply[strlen(reply)-1] == ',')
- reply[strlen(reply)-1] = '\0';
+ (void)snprintf(reply+strlen(reply), replylen-strlen(reply),
+ "\"native\":%d,\"bps\":%d,\"parity\":\"%c\",\"stopbits\":%u,\"cycle\":%2.2f",
+ device->gpsdata.dev.driver_mode,
+ (int)gpsd_get_speed(&device->ttyset),
+ (int)device->gpsdata.dev.parity,
+ device->gpsdata.dev.stopbits,
+ device->gpsdata.dev.cycle);
+ if (device->device_type->rate_switcher != NULL)
+ (void)snprintf(reply+strlen(reply), replylen-strlen(reply),
+ ",\"mincycle\":%2.2f",
+ device->device_type->min_cycle);
(void)strlcat(reply, "}", replylen);
}