Skip to content

Commit

Permalink
Improve start of frame detection
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi committed Dec 29, 2024
1 parent ae0afde commit 2933306
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/jk_modbus/jk_modbus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ bool JkModbus::parse_jk_modbus_byte_(uint8_t byte) {
const uint8_t *raw = &this->rx_buffer_[0];

// Byte 0: Start sequence (0x4E)
if (at == 0)
if (at == 0) {
if (raw[0] != 0x4E) {
// return false to reset buffer
return false;
}

return true;
}
uint8_t address = raw[0];

// Byte 1: Start sequence (0x57)
Expand Down

0 comments on commit 2933306

Please sign in to comment.