Skip to content

Commit a108cf4

Browse files
committed
Add badCrc for SBF and SPARTN
1 parent 025ac73 commit a108cf4

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/Parse_SBF.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ bool sempSbfReadBytes(SEMP_PARSE_STATE *parse, uint8_t data)
3333
{
3434
parse->state = sempFirstByte;
3535

36-
if (scratchPad->sbf.computedCRC == scratchPad->sbf.expectedCRC)
36+
if ((scratchPad->sbf.computedCRC == scratchPad->sbf.expectedCRC)
37+
|| (parse->badCrc && (!parse->badCrc(parse))))
3738
{
3839
parse->eomCallback(parse, parse->type); // Pass parser array index
3940
}

src/Parse_SPARTN.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,19 @@ bool sempSpartnReadTF018(SEMP_PARSE_STATE *parse, uint8_t data)
3636
case 0:
3737
{
3838
uint8_t expected = *ptr;
39-
valid = (semp_uSpartnCrc8(&parse->buffer[1], numBytes - 1) == expected); // Don't include the preamble in the CRC
39+
// Don't include the preamble in the CRC
40+
valid = ((semp_uSpartnCrc8(&parse->buffer[1], numBytes - 1) == expected)
41+
|| (parse->badCrc && (!parse->badCrc(parse))));
4042
}
4143
break;
4244
case 1:
4345
{
4446
uint16_t expected = *ptr++;
4547
expected <<= 8;
4648
expected |= *ptr;
47-
valid = (semp_uSpartnCrc16(&parse->buffer[1], numBytes - 1) == expected); // Don't include the preamble in the CRC
49+
// Don't include the preamble in the CRC
50+
valid = ((semp_uSpartnCrc16(&parse->buffer[1], numBytes - 1) == expected)
51+
|| (parse->badCrc && (!parse->badCrc(parse))));
4852
}
4953
break;
5054
case 2:
@@ -54,7 +58,9 @@ bool sempSpartnReadTF018(SEMP_PARSE_STATE *parse, uint8_t data)
5458
expected |= *ptr++;
5559
expected <<= 8;
5660
expected |= *ptr;
57-
valid = (semp_uSpartnCrc24(&parse->buffer[1], numBytes - 1) == expected); // Don't include the preamble in the CRC
61+
// Don't include the preamble in the CRC
62+
valid = ((semp_uSpartnCrc24(&parse->buffer[1], numBytes - 1) == expected)
63+
|| (parse->badCrc && (!parse->badCrc(parse))));
5864
}
5965
break;
6066
default:
@@ -66,7 +72,9 @@ bool sempSpartnReadTF018(SEMP_PARSE_STATE *parse, uint8_t data)
6672
expected |= *ptr++;
6773
expected <<= 8;
6874
expected |= *ptr;
69-
valid = (semp_uSpartnCrc32(&parse->buffer[1], numBytes - 1) == expected); // Don't include the preamble in the CRC
75+
// Don't include the preamble in the CRC
76+
valid = ((semp_uSpartnCrc32(&parse->buffer[1], numBytes - 1) == expected)
77+
|| (parse->badCrc && (!parse->badCrc(parse))));
7078
}
7179
break;
7280
}

0 commit comments

Comments
 (0)