diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-08-27 10:33:34 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-08-27 10:33:34 +0000 |
commit | c083980a2b24da5ab8e0c223d19cfa46d82465ac (patch) | |
tree | 221a092398d6ebfa2b1a9dc986c24884bbca84b2 /rtcm2_json.c | |
parent | a843dba83020d1eb4f3c74ea250107e9fb15a874 (diff) | |
download | gpsd-c083980a2b24da5ab8e0c223d19cfa46d82465ac.tar.gz |
Parse JSON for RTCM2 message types 1 and 9.
Diffstat (limited to 'rtcm2_json.c')
-rw-r--r-- | rtcm2_json.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/rtcm2_json.c b/rtcm2_json.c index 35f37360..523d3d2a 100644 --- a/rtcm2_json.c +++ b/rtcm2_json.c @@ -39,10 +39,23 @@ int json_rtcm2_read(const char *buf, {"length", uinteger, .addr.uinteger = &rtcm2->length}, \ {"station_health", uinteger, .addr.uinteger = &rtcm2->stathlth}, - int status; + int status, satcount; + const struct json_attr_t json_rtcm1_satellite[] = { + {"ident", uinteger, .addr.offset=offsetof(struct rangesat_t, ident)}, + {"udre", uinteger, .addr.offset=offsetof(struct rangesat_t, udre)}, + {"issuedata", real, .addr.offset=offsetof(struct rangesat_t, issuedata)}, + {"rangerr", real, .addr.offset=offsetof(struct rangesat_t, rangerr)}, + {"rangerate", real, .addr.offset=offsetof(struct rangesat_t, rangerate)}, + {NULL}, + }; const struct json_attr_t json_rtcm1[] = { - // FIXME RTCM2_HEADER + {"satellites", array, .addr.array.element_type = structobject, + .addr.array.arr.objects.base = (char*)rtcm2->ranges.sat, + .addr.array.arr.objects.stride = sizeof(rtcm2->ranges.sat[0]), + .addr.array.arr.objects.subtype = json_rtcm1_satellite, + .addr.array.count = &satcount, + .addr.array.maxlen = NITEMS(rtcm2->ranges.sat)}, {NULL}, }; @@ -109,9 +122,11 @@ int json_rtcm2_read(const char *buf, memset(rtcm2, '\0', sizeof(struct rtcm2_t)); - if (strstr(buf, "\"type\":1") != NULL || strstr(buf, "\"type\":9") != NULL) + if (strstr(buf, "\"type\":1")!=NULL || strstr(buf, "\"type\":9")!=NULL) { status = json_read_object(buf, json_rtcm1, endptr); - else if (strstr(buf, "\"type\":3") != NULL) + if (status == 0) + rtcm2->ranges.nentries = (unsigned)satcount; + } else if (strstr(buf, "\"type\":3") != NULL) status = json_read_object(buf, json_rtcm3, endptr); else if (strstr(buf, "\"type\":4") != NULL) { status = json_read_object(buf, json_rtcm4, endptr); |