Skip to content

fix: preserve Modbus target identity and explicit TCP unit zero - #3

Merged
KaiserIIII merged 1 commit into
mainfrom
codex/modbus-identity-20261016
Oct 16, 2026
Merged

KaiserIIII merged 1 commit into
mainfrom
codex/modbus-identity-20261016

Conversation

@KaiserIIII

Copy link
Copy Markdown
Owner

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).

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.
@KaiserIIII
KaiserIIII merged commit ad433e4 into main Oct 16, 2026
8 checks passed
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