Skip to content

Commit

Permalink
[transport] generate log message on crc error
Browse files Browse the repository at this point in the history
  • Loading branch information
r00t- committed Feb 14, 2023
1 parent 74e18fc commit 64c5e2c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sml/src/sml_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ sml_message *sml_message_parse(sml_buffer *buf) {
goto error;
}

if (*msg->crc != sml_crc16_calculate(&(buf->buffer[msg_start]), len))
if (
*msg->crc != sml_crc16_calculate(&(buf->buffer[msg_start]), len) &&
// Workaround for Holley DTZ541 uses CRC-16/Kermit
if (*msg->crc != sml_crc16kermit_calculate(&(buf->buffer[msg_start]), len))
goto error;
*msg->crc != sml_crc16kermit_calculate(&(buf->buffer[msg_start]), len)
){
fprintf(stderr, "libsml: sml_message_parse(): crc mismatch, dropping message\n");
goto error;
}

if (buf->cursor >= buf->buffer_len) {
buf->error = 1;
Expand Down

0 comments on commit 64c5e2c

Please sign in to comment.