Skip to content

Conversation

lmartorella
Copy link

Hi,
I've found an issue in cleaning up the RTU module state, that happens in one of the following cases of incoming packet:

  • a CRC error is detected (e.g. malformed packet or transmission error due to noisy line);
  • a custom cbRaw callback is installed and a EX_PASSTHROUGH is returned when the frame was not valid, but the CRC was ok;

In these cases, the state of the receiver is not correctly reset, and it is impossible to send new packets (e.g. the send() always returns false) until the timeout elapsed. This is because the cleanup() function only acts after MODBUSRTU_TIMEOUT_US timeout.

Setting _slaveId = 0 at the end of the task() fixes the issue.
It is also probably better to get rid of the goto used in the task() function and linting it.

Thanks!
L

@lmartorella lmartorella changed the title - FIxed error recovery - Fixed error recovery Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant