@@ -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