Backport robustness improvements from python-s7comm#580
Merged
gijzelaerr merged 1 commit intomasterfrom Feb 27, 2026
Merged
Conversation
nikteliy
approved these changes
Feb 25, 2026
922b5bd to
8ed1fcc
Compare
Backports concrete robustness improvements from nikteliy/python-s7comm to the native Python S7 implementation: - 210+ S7 protocol error codes from Wireshark's S7 dissector covering USERDATA parameter errors (0xD0xx), protocol errors (0x8xxx), and resource errors. parse_response() now raises descriptive S7ProtocolError on header errors, and USERDATA response parsing logs warnings. - Stale packet detection with retry: new validate_pdu_reference() validates response sequence numbers. New _send_receive() helper wraps the send/receive/parse pattern with automatic retry on stale packets (up to 3 retries). Refactored ~15 call sites in client.py to use it. - Automatic PDU splitting for read_area()/write_area(): requests exceeding the negotiated PDU length are automatically chunked, preventing PLC rejections on large reads (e.g. db_get() on big DBs). - TPDUSize enum (ISO 8073) with configurable COTP negotiation: replaces hardcoded 0x0A with a proper IntEnum (128-8192 bytes). - MAX_VARS=20 limit on read_multi_vars()/write_multi_vars(): raises ValueError when exceeding the S7 protocol limit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8ed1fcc to
c3b54dd
Compare
nikteliy
approved these changes
Feb 27, 2026
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
Backports concrete robustness improvements from nikteliy/python-s7comm to the native Python S7 implementation:
parse_response()now raises descriptiveS7ProtocolErroron header errors, and USERDATA response parsing logs descriptive warnings.validate_pdu_reference()validates response sequence numbers. New_send_receive()helper wraps the send→receive→parse pattern with automatic retry on stale packets (up to 3 retries). Refactored ~15 call sites inclient.pyto use it.read_area()/write_area()— requests exceeding the negotiated PDU length are automatically chunked, preventing PLC rejections on large reads (e.g.,db_get()on big DBs).0x0Awith a properTPDUSizeIntEnum (128–8192 bytes).read_multi_vars()/write_multi_vars()— raisesValueErrorwhen exceeding the S7 protocol limit.Not incorporated: async client, Protocol-based typing, packet-per-class architecture, PCAP-based testing.
Test plan
tests/test_improvements.pycovering all featuresruff check,ruff format --check,mypyall pass clean🤖 Generated with Claude Code