diff options
-rw-r--r-- | driver_rtcm3.c | 16 | ||||
-rw-r--r-- | drivers.c | 14 | ||||
-rw-r--r-- | gps.h | 4 | ||||
-rw-r--r-- | gpsd_json.c | 6 | ||||
-rw-r--r-- | test/packet.test.chk | 4 | ||||
-rw-r--r-- | test_packet.c | 18 |
6 files changed, 37 insertions, 25 deletions
diff --git a/driver_rtcm3.c b/driver_rtcm3.c index 3ea85689..382539d1 100644 --- a/driver_rtcm3.c +++ b/driver_rtcm3.c @@ -89,8 +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)); + gpsd_report(LOG_RAW, "RTCM3: type %d payload length %d: %s\n", + rtcm->type, rtcm->length, + gpsd_hexdump_wrapper(buf+3, rtcm->length, LOG_RAW)); switch (rtcm->type) { case 1001: /* GPS Basic RTK, L1 Only */ @@ -211,12 +212,12 @@ void rtcm3_unpack( /*@out@*/ struct rtcm3_t *rtcm, char *buf) ugrab(2); R1005.ecef_z = sgrab(38) * ANTENNA_POSITION_RESOLUTION; #undef R1005 - assert(bitcount == 152); break; case 1006: /* Stationary Antenna Reference Point, with Height Information */ #define R1006 rtcm->rtcmtypes.rtcm3_1006 R1006.station_id = (unsigned short)ugrab(12); + ugrab(6); /* reserved */ temp = ugrab(3); if ((temp & 0x04)!=0) R1006.system = NAVSYSTEM_GPS; @@ -224,7 +225,6 @@ void rtcm3_unpack( /*@out@*/ struct rtcm3_t *rtcm, char *buf) R1006.system = NAVSYSTEM_GLONASS; if ((temp & 0x01)!=0) R1006.system = NAVSYSTEM_GALILEO; - ugrab(6); /* reserved */ R1006.reference_station = (bool)ugrab(1); R1006.ecef_x = sgrab(38) * ANTENNA_POSITION_RESOLUTION; R1006.single_receiver = ugrab(1); @@ -418,11 +418,9 @@ void rtcm3_unpack( /*@out@*/ struct rtcm3_t *rtcm, char *buf) rtcm->rtcmtypes.rtcm3_1029.mjd = (unsigned short)ugrab(16); rtcm->rtcmtypes.rtcm3_1029.sod = (unsigned short)ugrab(17); rtcm->rtcmtypes.rtcm3_1029.len = (unsigned long)ugrab(7); - n = rtcm->rtcmtypes.rtcm3_1029.unicode_units = - (unsigned long)ugrab(8); - (void)memcpy(rtcm->rtcmtypes.rtcm3_1029.text, buf + 9, n); - bitcount += 8 * n; - assert(bitcount == (int)(72 + 8 * n)); + n = rtcm->rtcmtypes.rtcm3_1029.unicode_units = (size_t)ugrab(8); + (void)memcpy(rtcm->rtcmtypes.rtcm3_1029.text, + buf + 12, rtcm->rtcmtypes.rtcm3_1029.unicode_units); break; default: @@ -934,15 +934,15 @@ static const struct gps_type_t rtcm104v2 = { static gps_mask_t rtcm104v3_analyze(struct gps_device_t *session) { - uint16_t length = getbeu16(session->packet.inbuffer, 1); uint16_t type = getbeu16(session->packet.inbuffer, 3) >> 4; - /* *INDENT-OFF* */ - gpsd_report(LOG_RAW, "RTCM 3.x packet type %d length %d words: %s\n", - type, length, gpsd_hexdump_wrapper(session->packet.inbuffer, - (size_t) (session->gpsdata.rtcm3.length), - LOG_RAW)); - /* *INDENT-ON* */ + gpsd_report(LOG_RAW, "RTCM 3.x packet %d type length %zd bytes: %s\n", + type, + session->packet.outbuflen, + gpsd_hexdump_wrapper(session->packet.outbuffer, + session->packet.outbuflen, + LOG_RAW)); + rtcm3_unpack(&session->gpsdata.rtcm3, (char *)session->packet.outbuffer); session->cycle_end_reliable = true; return RTCM3_IS; } @@ -494,8 +494,8 @@ struct rtcm3_t { unsigned int station_id; /* Reference Station ID */ unsigned short mjd; /* Modified Julian Day (MJD) Number */ unsigned int sod; /* Seconds of Day (UTC) */ - unsigned char len; /* # Chars to follow */ - unsigned char unicode_units; + size_t len; /* # chars to follow */ + size_t unicode_units; /* # Unicode units in text */ unsigned char text[128]; } rtcm3_1029; char data[1024]; /* Max RTCM3 msg length is 1023 bytes */ diff --git a/gpsd_json.c b/gpsd_json.c index cd686f64..a4de2021 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -1257,12 +1257,12 @@ void json_rtcm3_dump(const struct rtcm3_t *rtcm, case 1029: (void)snprintf(buf + strlen(buf), buflen - strlen(buf), "\"station_id\":%u,\"mjd\":%u,\"sec\":%u," - "\"len\":%u,\"units\":%u,\"msg\"=\"%s\",", + "\"len\":%zd,\"units\":%zd,\"msg\"=\"%s\",", rtcm->rtcmtypes.rtcm3_1029.station_id, rtcm->rtcmtypes.rtcm3_1029.mjd, rtcm->rtcmtypes.rtcm3_1029.sod, - INT(rtcm->rtcmtypes.rtcm3_1029.len), - INT(rtcm->rtcmtypes.rtcm3_1029.unicode_units), + rtcm->rtcmtypes.rtcm3_1029.len, + rtcm->rtcmtypes.rtcm3_1029.unicode_units, json_stringify(buf1, sizeof(buf1), (char *)rtcm->rtcmtypes.rtcm3_1029.text)); break; diff --git a/test/packet.test.chk b/test/packet.test.chk index c487ce7c..e615ca4b 100644 --- a/test/packet.test.chk +++ b/test/packet.test.chk @@ -16,9 +16,7 @@ 15: EverMore packet 0x04, 0x10 three times at the beginning test succeeded. 16: RTCM104V3 type 1005 packet test succeeded. 17: RTCM104V3 type 1005 packet with 4th byte garbled test succeeded. +18: RTCM104V3 type 1029 packet test succeeded. === EOF with buffer nonempty test === $GPVTG,308.74,T,,M,0.00,N,0.0,K*68
$GPGGA,110534.994,4002.1425,N,07531.2585,W,0,00,50.0,172.7,M,-33.8,M,0.0,0000*7A
-packet_parse() returned 36 -packet_parse() returned 82 -packet_parse() returned 0 diff --git a/test_packet.c b/test_packet.c index b2e98197..274ecc33 100644 --- a/test_packet.c +++ b/test_packet.c @@ -205,6 +205,7 @@ static struct map singletests[] = { .type = EVERMORE_PACKET, }, { + /* from page 4-3 of the RTCM3.0 standard */ .legend = "RTCM104V3 type 1005 packet", /* * Reference Station Id = 2003 @@ -235,6 +236,21 @@ static struct map singletests[] = { .garbage_offset = 0, .type = BAD_PACKET, }, + { + /* from page 3-71 of the RTCM3.0 standard */ + .legend = "RTCM104V3 type 1029 packet", + .test = { + 0xD3, 0x00, 0x27, 0x40, 0x50, 0x17, 0x00, 0x84, + 0x73, 0x6E, 0x15, 0x1E, 0x55, 0x54, 0x46, 0x2D, + 0x38, 0x20, 0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xBE, + 0xD0, 0xB2, 0xD0, 0xB5, 0xD1, 0x80, 0xD0, 0xBA, + 0xD0, 0xB0, 0x20, 0x77, 0xC3, 0xB6, 0x72, 0x74, + 0x65, 0x72, 0xED, 0xA3, 0x3B + }, + .testlen = 45, + .garbage_offset = 0, + .type = RTCM3_PACKET, + }, }; /*@ +initallelements -charint +usedef @*/ /* *INDENT-ON* */ @@ -310,7 +326,7 @@ static void runon_test(struct map *mp) (void)fputs(mp->test, stdout); do { st = packet_get(nullfd, &packet); - printf("packet_parse() returned %zd\n", st); + //printf("packet_parse() returned %zd\n", st); } while (st > 0); /*@ +compdef +uniondef +usedef +formatcode @*/ } |