Fix modbus user-defined function handling (#3527)

This commit is contained in:
gazoodle 2022-06-17 02:35:25 +01:00 committed by GitHub
parent c8b58b5c23
commit 29d6d0a906
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,7 +76,12 @@ bool Modbus::parse_modbus_byte_(uint8_t byte) {
// installed, but wait, there is the CRC, and if we get a hit there is a good
// chance that this is a complete message ... admittedly there is a small chance is
// isn't but that is quite small given the purpose of the CRC in the first place
data_len = at;
// Fewer than 2 bytes can't calc CRC
if (at < 2)
return true;
data_len = at - 2;
data_offset = 1;
uint16_t computed_crc = crc16(raw, data_offset + data_len);