Fixed "get_cpu_info" and "__str__" in structure "S7SZL"#692
Merged
gijzelaerr merged 3 commits intogijzelaerr:masterfrom Apr 15, 2026
Merged
Fixed "get_cpu_info" and "__str__" in structure "S7SZL"#692gijzelaerr merged 3 commits intogijzelaerr:masterfrom
gijzelaerr merged 3 commits intogijzelaerr:masterfrom
Conversation
Fix in structure "S7SZL" function "__str__", previusly gave error "AttributeError: 'S7SZL' object has no attribute 'S7SZHeader'"
Fixed function get_cpu_info, it returned all the field empty. Now tested working on s7-300 and s7-1500, same output as the old python-snap7 2.1.1.
Fixed function get_cpu_info, it returned all the field empty. Now tested working on s7-300 and s7-1500, same output as the old python-snap7 2.1.1.
gijzelaerr
added a commit
that referenced
this pull request
Apr 15, 2026
PR #692 corrected get_cpu_info field offsets to match real S7-300/1500 SZL responses. The server emulator was using a simplified sequential layout that didn't match. Update the server to place fields at the correct offsets (ASName@6, ModuleName@40, Copyright@108, SerialNumber@142, ModuleTypeName@176). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gijzelaerr
added a commit
that referenced
this pull request
Apr 15, 2026
PR #692 corrected get_cpu_info field offsets to match real S7-300/1500 SZL responses. The server emulator was using a simplified sequential layout that didn't match. Update the server to place fields at the correct offsets (ASName@6, ModuleName@40, Copyright@108, SerialNumber@142, ModuleTypeName@176). Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
gijzelaerr
added a commit
that referenced
this pull request
Apr 21, 2026
* Fix async get_cpu_info SZL offsets to match sync Discussion #700 reports that AsyncClient.get_cpu_info() returns empty fields against a real PLC. Root cause: PR #692 fixed the offsets in the sync Client (0,32,56,80,106,130 → 6,30,40,64,108,134,142,166, 176,208 with the correct field ordering) and #694 updated the server emulator to match, but async_client.py was never touched and kept the pre-#692 layout. Ports the same offsets to the async client so sync/async produce identical output against both real PLCs and the server emulator. Strengthens the async test to assert specific field values (matching the sync test) instead of just checking attribute presence — the prior smoke test passed even with all-empty fields. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Extract SZL and block parsers shared by sync and async clients Follow-on to the async get_cpu_info fix: the root cause was that parsing logic for SZL records (and the block-info dict→struct copy) lived inline in both Client and AsyncClient, so a fix to one side silently drifted from the other. - New snap7/szl.py module with parse_{cpu_info,cp_info,order_code, protection}_szl(szl) helpers. Both clients call them; offsets and field definitions exist in exactly one place. - Two new non-SZL converters live alongside the existing protocol parsers in s7protocol.py (build_blocks_list_from_dict, build_block_info_from_dict) exposed as S7Protocol.parse_list_blocks / S7Protocol.parse_get_block_info. The clients' dict→struct copies disappear. - Strengthened async tests for list_blocks, get_cp_info, get_order_code, get_protection, get_block_info — the previous tests only did hasattr() checks and so could not catch a value regression. They now assert the same concrete values the sync suite asserts. Net: clients shrink by ~280 lines, parsing surface is unified, and the async tests carry the same safety net as sync. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Fix in structure "S7SZL" function "__str__" in file "snap7/type.py", previously gave error "AttributeError: 'S7SZL' object has no attribute 'S7SZHeader'"
Fixed function get_cpu_info in file "snap7/client.py", it returned all the field empty.
Now tested working on s7-300 and s7-1500, same output as the old python-snap7 2.1.1.