Repository navigation
fix: preserve Modbus target identity and explicit TCP unit zero - #3
Merged
Merged
Conversation
Reject target aliasing at configuration, encoding and response boundaries. Preserve explicit TCP unit 0 in configured and discovery probes. AI-assisted implementation and regression tests; 275 local tests passed.
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.
Invalid Modbus target IDs could identify the wrong device: for example, configured 257 encoded as byte 1 and a unit-1 response also matched expected 257. Numeric TCP unit 0 was separately changed to 1 in configured and discovery probes.
Add a shared target guard at configuration, request encoding and expected-response boundaries. RTU response-bearing reads allow unicast 1–247; TCP retains 0–255, including explicit 0/255. Missing identifiers still default 1, and configuration keeps numeric-string/exact-integral-float compatibility. No transport, task, database, CSV or gameplay redesign.
Validation: 275 local pytest tests pass (61 new cases); the new byte roundtrip properties cover 503 legal targets inside two tests. FakeSocket exercises TCP zero in configured/discovery flows, and loopback HTTP rejects target aliases without creating jobs. Configuration validation, 23 offline self-checks and a zero-package pure smoke pass. Broad runtime coverage remains about 51.42% line/40.40% branch; this is not full hardware or security certification.
The corrected test suite was rerun against the original main and recorded 55 failures / 6 passes before becoming 61/61. Two initial test method-name errors are retained in the local audit and are not reported as product bugs. Implementation, tests and this description are AI-assisted.
Protocol contract: https://www.modbus.org/file/secure/messagingimplementationguide.pdf (MBAP fields and target routing,pp5–6/23).