Skip to content

Commit 9260600

Browse files
authored
Merge pull request #51 from sparkfun/pcUpdates
Handle zero payload RTCM and UBX correctly
2 parents 5cd2d72 + d79dad3 commit 9260600

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun Extensible Message Parser
2-
version=1.0.4
2+
version=1.0.5
33
author=SparkFun Electronics
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library to parse structured serial streams

src/Parse_RTCM.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ bool sempRtcmReadCrc(SEMP_PARSE_STATE *parse, uint8_t data)
6060

6161
// Process the message if CRC is valid
6262
if ((parse->crc == 0) || (parse->badCrc && (!parse->badCrc(parse))))
63+
{
64+
if (parse->length == 6)
65+
sempPrintf(parse->printDebug,
66+
"SEMP: %s RTCM 0x%04x (%d) bytes, \"filler\" message",
67+
parse->parserName,
68+
parse->length, parse->length);
6369
parse->eomCallback(parse, parse->type); // Pass parser array index
70+
}
6471

6572
// Display the RTCM messages with bad CRC
6673
else
@@ -128,7 +135,15 @@ bool sempRtcmReadLength2(SEMP_PARSE_STATE *parse, uint8_t data)
128135
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad;
129136

130137
scratchPad->rtcm.bytesRemaining |= data;
131-
parse->state = sempRtcmReadMessage1;
138+
if (scratchPad->rtcm.bytesRemaining == 0) // Handle zero length messages - 10403 "filler" messages
139+
{
140+
scratchPad->rtcm.message = 0; // Clear the previous message number
141+
scratchPad->rtcm.crc = parse->crc;
142+
scratchPad->rtcm.bytesRemaining = 3;
143+
parse->state = sempRtcmReadCrc; // Jump to the CRC
144+
}
145+
else
146+
parse->state = sempRtcmReadMessage1;
132147
return true;
133148
}
134149

src/Parse_UBLOX.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ bool sempUbloxLength2(SEMP_PARSE_STATE *parse, uint8_t data)
101101

102102
// Save the second length byte
103103
scratchPad->ublox.bytesRemaining |= ((uint16_t)data) << 8;
104-
parse->state = sempUbloxPayload;
104+
if (scratchPad->ublox.bytesRemaining == 0) // Handle zero length messages - e.g. UBX-UPD
105+
parse->state = sempUbloxCkA; // Jump to CRC
106+
else
107+
parse->state = sempUbloxPayload;
105108
return true;
106109
}
107110

src/SparkFun_Extensible_Message_Parser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ License: MIT. Please see LICENSE.md for more details
2222
// Macros
2323
//----------------------------------------
2424

25+
// Align x to multiples of 8: 0->0; 1->8; 8->8; 9->16
2526
#define SEMP_ALIGN(x) ((x + SEMP_ALIGNMENT_MASK) & (~SEMP_ALIGNMENT_MASK))
2627

2728
//----------------------------------------

0 commit comments

Comments
 (0)