Skip to content

Commit

Permalink
Improve start of frame detection (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Dec 29, 2024
1 parent ae0afde commit 923bb2a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/jk_modbus/jk_modbus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ 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)
return true;
if (at == 0) {
// return false to reset buffer
return raw[0] == 0x4E;
}
uint8_t address = raw[0];

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

0 comments on commit 923bb2a

Please sign in to comment.