@@ -36,15 +36,19 @@ bool sempSpartnReadTF018(SEMP_PARSE_STATE *parse, uint8_t data)
36
36
case 0 :
37
37
{
38
38
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))));
40
42
}
41
43
break ;
42
44
case 1 :
43
45
{
44
46
uint16_t expected = *ptr++;
45
47
expected <<= 8 ;
46
48
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))));
48
52
}
49
53
break ;
50
54
case 2 :
@@ -54,7 +58,9 @@ bool sempSpartnReadTF018(SEMP_PARSE_STATE *parse, uint8_t data)
54
58
expected |= *ptr++;
55
59
expected <<= 8 ;
56
60
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))));
58
64
}
59
65
break ;
60
66
default :
@@ -66,7 +72,9 @@ bool sempSpartnReadTF018(SEMP_PARSE_STATE *parse, uint8_t data)
66
72
expected |= *ptr++;
67
73
expected <<= 8 ;
68
74
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))));
70
78
}
71
79
break ;
72
80
}
0 commit comments