Repository navigation
Answer ILLEGAL_VALUE for a Write Single Coil value other than 0x0000/0xFF00 - #3074
Merged
janiversen merged 1 commit intoOct 31, 2026
Merged
Conversation
…0xFF00 The specification (6.5) allows only 0xFF00 (ON) and 0x0000 (OFF); any other value is illegal, must not affect the coil, and gets exception 03. The server took any non-zero value as ON and echoed 0xFF00. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
janiversen
approved these changes
Oct 31, 2026
janiversen
left a comment
Collaborator
There was a problem hiding this comment.
Your change is correct and according to the protocol documentation !
However many devices hace a more relaxed implementación, that says 0x00 is OFF and all other values are ON.
Collaborator
|
Feel cree to open issues or make more PR, if you find other differences that also are not in the standard. |
Collaborator
|
Refactored and added to PR #3068 (test from this PR is kept original to verify, it is implemented correctly). |
carlok
added a commit
to carlok/pymodbus
that referenced
this pull request
Nov 1, 2026
The conflict was in test/server/test_server_asyncio.py: pymodbus-dev#3074 and this branch each added a server test at the same place. Both are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 Write Single Coil request (0x05) with a value other than 0xFF00 or 0x0000 was carried out. Any non-zero value turned the coil ON, and the response echoed 0xFF00, a value the client didn't send. The Modbus Application Protocol (V1.1b3, 6.5) says "All other values are illegal and will not affect the output", and its state diagram answers exception 03.
The change:
WriteSingleCoilRequestkeeps the decoded value, anddatastore_updateanswersILLEGAL_VALUEfor any other value before it touches the datastore. That is the same place #3066 checks counts. A request built through the API (no decoded value) is unchanged.Tests:
05 0000 0001now gets85 03. Before, it got05 0000 ff00and the coil was turned ON.dev(b9cd6c6) and pass here. codespell, ruff, pylint, zuban and pytest (100 % coverage) pass.Found by a differential test against libmodbus, which answers exception 03 to the same request.
🤖 Generated with Claude Code