Repository navigation
Conversation
A request whose function code is 0x80 to 0xFF (reserved for exception responses) got an exception whose function byte wrapped around: 0x81 was answered 0x01 0x01, which reads as a Read Coils response with a byte count of 1 and no data. The client then waits for that data byte. Building the byte with | 0x80 keeps the exception bit set and changes nothing for valid function codes.
|
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.
A request whose function code is 0x80 to 0xFF gets an exception response whose function byte wraps around.
response_exception()builds that byte assft->function + 0x80in a byte.modbus_reply_exception()does the same.81 00 00is answered01 01. That reads as a Read Coils response with a byte count of 1 and no data, so the client waits for a data byte that never comes. For 0x80 the function byte becomes 0x00.The change:
| 0x80in both places. Nothing changes for valid function codes, whose high bit is clear.The test:
unit-test-client.csends the raw request81 00 00 00 00. It expects exception 01 with the function byte 0x81. It fails on master and passes here.tests/unit-tests.shandmake distcheckpass.Found by a differential test against pymodbus.
🤖 Generated with Claude Code