diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-05-01 15:53:59 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-05-01 15:53:59 -0400 |
commit | f719fbf8cf20f9d709472cea3e10e142f5ca4ee7 (patch) | |
tree | 4e5e59148ab6a3e46faadde491fe8b49f7c97ad2 /rtcm3_json.c | |
parent | 488ddabb2080e73d5c900fed6064332ee14c637b (diff) | |
download | gpsd-f719fbf8cf20f9d709472cea3e10e142f5ca4ee7.tar.gz |
Unpack JSON for RTCM3 R1007, R1008, and R1009.
Diffstat (limited to 'rtcm3_json.c')
-rw-r--r-- | rtcm3_json.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/rtcm3_json.c b/rtcm3_json.c index c90a62e1..fd6ea0c0 100644 --- a/rtcm3_json.c +++ b/rtcm3_json.c @@ -65,6 +65,17 @@ int json_rtcm3_read(const char *buf, {NULL}, }; + const struct json_attr_t rtcm1009_satellite[] = { + {"ident", t_uinteger, STRUCTOBJECT(struct rtcm3_1009_t, ident)}, + {"ind", t_uinteger, STRUCTOBJECT(struct rtcm3_1009_t, L1.indicator)}, + {"channel", t_uinteger, STRUCTOBJECT(struct rtcm3_1009_t, L1.channel)}, + {"prange", t_real, STRUCTOBJECT(struct rtcm3_1009_t, L1.pseudorange)}, + {"delta", t_real, STRUCTOBJECT(struct rtcm3_1009_t, L1.rangediff)}, + + {"lockt", t_uinteger, STRUCTOBJECT(struct rtcm3_1009_t, L1.locktime)}, + {NULL}, + }; + /*@-type@*//* STRUCTARRAY confuses splint */ #define R1001 &rtcm3->rtcmtypes.rtcm3_1001.header const struct json_attr_t json_rtcm1001[] = { @@ -97,6 +108,50 @@ int json_rtcm3_read(const char *buf, #undef R1002 /*@+type@*/ + /*@-type@*//* STRUCTARRAY confuses splint */ +#define R1007 rtcm3->rtcmtypes.rtcm3_1007 + const struct json_attr_t json_rtcm1007[] = { + RTCM3_HEADER + {"station_id", t_uinteger, .addr.uinteger = &R1007.station_id}, + {"desc", t_string, .addr.string = R1007.descriptor, + .len = sizeof(R1007.descriptor)}, + {"setup_id", t_uinteger, .addr.uinteger = &R1007.setup_id}, + {NULL}, + }; +#undef R1002 + /*@+type@*/ + + /*@-type@*//* STRUCTARRAY confuses splint */ +#define R1008 rtcm3->rtcmtypes.rtcm3_1008 + const struct json_attr_t json_rtcm1008[] = { + RTCM3_HEADER + {"station_id", t_uinteger, .addr.uinteger = &R1008.station_id}, + {"desc", t_string, .addr.string = R1008.descriptor, + .len = sizeof(R1008.descriptor)}, + {"setup_id", t_uinteger, .addr.uinteger = &R1008.setup_id}, + {NULL}, + {"serial", t_string, .addr.string = R1008.serial, + .len = sizeof(R1008.serial)}, + }; +#undef R1008 + /*@+type@*/ + + /*@-type@*//* STRUCTARRAY confuses splint */ +#define R1009 &rtcm3->rtcmtypes.rtcm3_1009.header + const struct json_attr_t json_rtcm1009[] = { + RTCM3_HEADER + {"station_id", t_uinteger, .addr.uinteger = R1009.station_id}, + {"tow", t_uinteger, .addr.uinteger = (unsigned int *)R1009.tow}, + {"sync", t_boolean, .addr.boolean = R1009.sync}, + {"smoothing", t_boolean, .addr.boolean = R1009.smoothing}, + {"interval", t_uinteger, .addr.uinteger = R1009.interval}, + {"satellites", t_array, STRUCTARRAY(rtcm3->rtcmtypes.rtcm3_1009.rtk_data, + rtcm1009_satellite, &satcount)}, + {NULL}, + }; +#undef R1009 + /*@+type@*/ + /*@-type@*//* complex union array initislizations confuses splint */ const struct json_attr_t json_rtcm3_fallback[] = { RTCM3_HEADER @@ -124,6 +179,12 @@ int json_rtcm3_read(const char *buf, status = json_read_object(buf, json_rtcm1002, endptr); if (status == 0) rtcm3->rtcmtypes.rtcm3_1002.header.satcount = (unsigned short)satcount; + } else if (strstr(buf, "\"type\":1007,") != NULL) { + status = json_read_object(buf, json_rtcm1007, endptr); + } else if (strstr(buf, "\"type\":1008,") != NULL) { + status = json_read_object(buf, json_rtcm1008, endptr); + } else if (strstr(buf, "\"type\":1009,") != NULL) { + status = json_read_object(buf, json_rtcm1009, endptr); } else { int n; status = json_read_object(buf, json_rtcm3_fallback, endptr); |