Implement low-level S7 Server and Partner classes for pure Python protocol support #2
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.
Overview
This PR implements pure Python versions of S7 Server and S7 Partner classes in the
snap7/low_levelmodule, based on the Sharp7 C# library reference. These implementations provide native Python alternatives that work without requiring the snap7 native library.Motivation
The existing
snap7/low_levelmodule had a partial S7 client implementation but was missing complete server and partner implementations. This PR completes the low-level implementation suite, enabling:Changes
New Files
snap7/low_level/s7_server.py(395 lines)snap7/low_level/s7_partner.py(488 lines)b_send(),b_recv()as_b_send(),as_b_recv()with completion callbackssnap7/low_level/s7_consts.pys7_isotcp.pyand other low-level componentsModified Files
snap7/low_level/__init__.pyS7ServerandS7Partner__all__list for proper module interfacesnap7/low_level/README.mdUsage Examples
S7Server
S7Partner
Implementation Details
S7Server Architecture
S7Partner Architecture
S7SocketclassCompatibility
Testing
Validation
✅ All Python syntax checks pass
✅ All linting checks pass (ruff)
✅ All formatting checks pass (ruff format)
✅ Imports verified working
✅ No breaking changes to existing code
References
Implementation based on:
snap7/low_level/s7_client.pyWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
192.168.1.235python -m pytest tests/ -v --tb=short(packet block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.