summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2018-10-24 18:46:57 -0700
committerGary E. Miller <gem@rellim.com>2018-10-24 18:46:57 -0700
commitafb75aeb519a2bbea6c1d081c936b1393c87b0a0 (patch)
tree233564d257ea89b8417ffd3c188ae7cbeecdf088
parent4a6b39d61494ce8ff89728287791f38f84e9719c (diff)
downloadgpsd-afb75aeb519a2bbea6c1d081c936b1393c87b0a0.tar.gz
Add RAW json messaage class for raw measurements.
Which bumps the JSON minor rev.
-rw-r--r--gps.h4
-rw-r--r--gps_json.h1
-rw-r--r--gpsd.h3
-rw-r--r--gpsd_json.c65
4 files changed, 71 insertions, 2 deletions
diff --git a/gps.h b/gps.h
index a4e6ed12..2469a9f5 100644
--- a/gps.h
+++ b/gps.h
@@ -41,8 +41,10 @@ extern "C" {
* increased length of devconfig_t.subtype
* add gnssid:svid:sigid to satellite_t
* add mtime to attitude_t
+ * changed MAXCHANNELS
+ * 8.0 - Change shape of rawdata_t.
*/
-#define GPSD_API_MAJOR_VERSION 7 /* bump on incompatible changes */
+#define GPSD_API_MAJOR_VERSION 8 /* bump on incompatible changes */
#define GPSD_API_MINOR_VERSION 0 /* bump on compatible changes */
#define MAXCHANNELS 120 /* u-blox 9 tracks 140 signals */
diff --git a/gps_json.h b/gps_json.h
index 95c1abe3..6bb61600 100644
--- a/gps_json.h
+++ b/gps_json.h
@@ -24,6 +24,7 @@ char *json_stringify(char *, size_t, const char *);
void json_tpv_dump(const struct gps_device_t *,
const struct gps_policy_t *, char *, size_t);
void json_noise_dump(const struct gps_data_t *, char *, size_t);
+void json_raw_dump(const struct gps_data_t *, char *, size_t);
void json_sky_dump(const struct gps_data_t *, char *, size_t);
void json_att_dump(const struct gps_data_t *, char *, size_t);
void json_oscillator_dump(const struct gps_data_t *, char *, size_t);
diff --git a/gpsd.h b/gpsd.h
index a1bd1c31..265f1580 100644
--- a/gpsd.h
+++ b/gpsd.h
@@ -52,10 +52,11 @@ extern "C" {
* 3.12 OSC message added to repertoire.
* 3.13 gnssid:svid added to SAT
* time added to ATT
+ * 3.14 Added RAW message class.
*/
/* Keep in sync with api_major_version and api_minor gps/__init__.py */
#define GPSD_PROTO_MAJOR_VERSION 3 /* bump on incompatible changes */
-#define GPSD_PROTO_MINOR_VERSION 13 /* bump on compatible changes */
+#define GPSD_PROTO_MINOR_VERSION 14 /* bump on compatible changes */
#define JSON_DATE_MAX 24 /* ISO8601 timestamp with 2 decimal places */
diff --git a/gpsd_json.c b/gpsd_json.c
index 3e7ff9aa..d999b3b3 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -718,6 +718,67 @@ void json_subframe_dump(const struct gps_data_t *datap,
(void)strlcat(buf, "}\r\n", buflen);
}
+/* RAW dump */
+void json_raw_dump(const struct gps_data_t *gpsdata,
+ char *reply, size_t replylen)
+{
+ int i;
+
+ assert(replylen > sizeof(char *));
+ (void)strlcpy(reply, "{\"class\":\"RAW\",", replylen);
+ if (gpsdata->dev.path[0] != '\0')
+ str_appendf(reply, replylen, "\"device\":\"%s\",", gpsdata->dev.path);
+
+ (void)strlcat(reply, "\"rawdata\":[", replylen);
+ for (i = 0; i < MAXCHANNELS; i++) {
+ bool comma = false;
+ if (0 == gpsdata->raw[i].mtime) {
+ continue;
+ }
+ (void)strlcat(reply, "{", replylen);
+ if (0 != isfinite(gpsdata->raw[i].codephase)) {
+ str_appendf(reply, replylen, "\"codephase\":\"%f\"",
+ gpsdata->raw[i].codephase);
+ comma = true;
+ }
+ if (0 != isfinite(gpsdata->raw[i].carrierphase)) {
+ if (comma)
+ (void)strlcat(reply, ",", replylen);
+ str_appendf(reply, replylen, "\"carrierphase\":\"%f\"",
+ gpsdata->raw[i].carrierphase);
+ comma = true;
+ }
+ if (0 != isfinite(gpsdata->raw[i].pseudorange)) {
+ if (comma)
+ (void)strlcat(reply, ",", replylen);
+ str_appendf(reply, replylen, "\"pseudorange\":\"%f\"",
+ gpsdata->raw[i].pseudorange);
+ comma = true;
+ }
+ if (0 != isfinite(gpsdata->raw[i].deltarange)) {
+ if (comma)
+ (void)strlcat(reply, ",", replylen);
+ str_appendf(reply, replylen, "\"deltarange\":\"%f\"",
+ gpsdata->raw[i].deltarange);
+ comma = true;
+ }
+ if (0 != isfinite(gpsdata->raw[i].doppler)) {
+ if (comma)
+ (void)strlcat(reply, ",", replylen);
+ str_appendf(reply, replylen, "\"doppler\":\"%f\"",
+ gpsdata->raw[i].doppler);
+ comma = true;
+ }
+
+ (void)strlcat(reply, "},", replylen);
+ }
+ str_rstrip_char(reply, ',');
+ (void)strlcat(reply, "]", replylen);
+
+ str_rstrip_char(reply, ',');
+ (void)strlcat(reply, "}\r\n", replylen);
+}
+
#if defined(RTCM104V2_ENABLE)
void json_rtcm2_dump(const struct rtcm2_t *rtcm,
const char *device,
@@ -3466,6 +3527,10 @@ void json_data_report(const gps_mask_t changed,
json_subframe_dump(datap, buf+strlen(buf), buflen-strlen(buf));
}
+ if ((changed & RAW_IS) != 0) {
+ json_raw_dump(datap, buf+strlen(buf), buflen-strlen(buf));
+ }
+
#ifdef COMPASS_ENABLE
if ((changed & ATTITUDE_SET) != 0) {
json_att_dump(datap, buf+strlen(buf), buflen-strlen(buf));