Add S7 routing support for multi-subnet PLC access#639
Open
gijzelaerr wants to merge 2 commits intomasterfrom
Open
Add S7 routing support for multi-subnet PLC access#639gijzelaerr wants to merge 2 commits intomasterfrom
gijzelaerr wants to merge 2 commits intomasterfrom
Conversation
Implement routing parameters in the COTP Connection Request PDU so clients can reach PLCs behind a gateway on another subnet. The new ISOTCPConnection.set_routing() method appends subnet ID (0xC6) and routing TSAP (0xC7) parameters to the CR, and Client.connect_routed() provides a high-level entry point that mirrors connect() but accepts gateway and destination rack/slot/subnet. Closes #615 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1b9f667 to
403fb61
Compare
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
ISOTCPConnection.set_routing()to embed subnet ID and routing TSAP parameters in the COTP Connection Request PDU, enabling connections through a gateway PLC to a target on another subnet.Client.connect_routed()as a high-level API that mirrorsconnect()but accepts gateway rack/slot and destination subnet/rack/slot.tests/test_routing.pycovering TSAP construction, COTP CR PDU generation with routing parameters, frame validity, and end-to-end routed connections against the built-in server.Closes #615
Test plan
uv run pytest tests/test_routing.py -v)uv run mypy snap7/connection.py snap7/client.py tests/test_routing.py)uv run ruff check snap7/connection.py snap7/client.py tests/test_routing.py)🤖 Generated with Claude Code