fix: keep waiting after unexpected RTU slave response#860
Open
MrAlaskan wants to merge 1 commit into
Open
Conversation
|
We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please fill https://forms.gle/5635zjphDo5JEJQSA to get added. Your document will be manually checked by the maintainer. Be patient... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix RTU confirmation handling to ensure that replies from unexpected slaves do not prematurely abort in-flight requests. See issue #861.
According to the Modbus Serial Line Protocol and Implementation Guide V1.02, if a master receives a frame from an unexpected slave while waiting for a response, it should discard the frame, keep the response timeout running, and remain in the "Waiting for reply" state.
Root Cause
The previous implementation handled unexpected slave replies inconsistently, violating the RTU master state machine:
EMBBADSLAVEerror.Fix
Introduced a dedicated
receive_confirmation()retry loop for RTU clients.Instead of aborting immediately when an
EMBBADSLAVEcondition is detected, the client now:response_timeoutETIMEDOUTThis aligns RTU confirmation handling with the Modbus RTU specification and avoids prematurely terminating valid in-flight requests.