From 1ca627ffdcd428375a6cebb556f516fe5251121d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 1 Mar 2011 10:06:05 -0500 Subject: A step towards decoding RTCM3. --- driver_rtcm3.c | 10 ++++++++-- gps.h | 2 +- gpsd_json.c | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/driver_rtcm3.c b/driver_rtcm3.c index d69cdf33..3ea85689 100644 --- a/driver_rtcm3.c +++ b/driver_rtcm3.c @@ -89,6 +89,9 @@ void rtcm3_unpack( /*@out@*/ struct rtcm3_t *rtcm, char *buf) rtcm->length = (uint)ugrab(10); rtcm->type = (uint)ugrab(12); + gpsd_report(LOG_RAW, "RTCM3: Raw packet type 0x%02x length %d: %s\n", + rtcm->type, rtcm->length, gpsd_hexdump_wrapper(buf, rtcm->length, LOG_RAW)); + switch (rtcm->type) { case 1001: /* GPS Basic RTK, L1 Only */ rtcm->rtcmtypes.rtcm3_1001.header.station_id = (uint)ugrab(12); @@ -423,8 +426,11 @@ void rtcm3_unpack( /*@out@*/ struct rtcm3_t *rtcm, char *buf) break; default: - //memcpy(tp->rtcmtypes.data, msg->msg_type.rtcm2_msgunk, - // (RTCM2_WORDS_MAX - 2) * sizeof(isgps30bits_t)); + /* + * Leader bytes, message length, and checksum won't be copied. + * The first 12 bits of the copied payload will be the type field. + */ + memcpy(rtcm->rtcmtypes.data, buf+3, rtcm->length); break; } #undef RANGEDIFF diff --git a/gps.h b/gps.h index 94275d14..73be4ded 100644 --- a/gps.h +++ b/gps.h @@ -498,7 +498,7 @@ struct rtcm3_t { unsigned char unicode_units; unsigned char text[128]; } rtcm3_1029; - char data[4096]; + char data[1024]; /* Max RTCM3 msg length is 1023 bytes */ } rtcmtypes; }; diff --git a/gpsd_json.c b/gpsd_json.c index afc0d554..cd686f64 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -879,6 +879,8 @@ void json_rtcm3_dump(const struct rtcm3_t *rtcm, "\"device\":\"%s\",", device); (void)snprintf(buf + strlen(buf), buflen - strlen(buf), "\"type\":%u,", rtcm->type); + (void)snprintf(buf + strlen(buf), buflen - strlen(buf), + "\"length\":%u,", rtcm->length); #define CODE(x) (unsigned int)(x) #define INT(x) (unsigned int)(x) -- cgit v1.2.1