Skip to content

Add S7 routing support for multi-subnet PLC access#639

Open
gijzelaerr wants to merge 2 commits intomasterfrom
feature/s7-routing
Open

Add S7 routing support for multi-subnet PLC access#639
gijzelaerr wants to merge 2 commits intomasterfrom
feature/s7-routing

Conversation

@gijzelaerr
Copy link
Owner

Summary

  • Add 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.
  • Add Client.connect_routed() as a high-level API that mirrors connect() but accepts gateway rack/slot and destination subnet/rack/slot.
  • Add 13 tests in tests/test_routing.py covering 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

  • All 13 new routing tests pass (uv run pytest tests/test_routing.py -v)
  • Full test suite passes (460 passed, 48 skipped)
  • mypy clean (uv run mypy snap7/connection.py snap7/client.py tests/test_routing.py)
  • ruff clean (uv run ruff check snap7/connection.py snap7/client.py tests/test_routing.py)

🤖 Generated with Claude Code

gijzelaerr and others added 2 commits March 20, 2026 12:47
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>
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.

S7 routing support for multi-subnet PLC access

1 participant