Fix UnicodeDecodeError/KeyError bugs, add ACD-to-L5X export, expand README#18
Merged
hutcheb merged 2 commits intohutcheb:mainfrom Mar 26, 2026
Merged
Fix UnicodeDecodeError/KeyError bugs, add ACD-to-L5X export, expand README#18hutcheb merged 2 commits intohutcheb:mainfrom
hutcheb merged 2 commits intohutcheb:mainfrom
Conversation
- fafa_coments.py: add errors='replace' to all .decode('UTF-8') calls so
controller comments with non-ASCII bytes no longer raise UnicodeDecodeError
- elements.py: guard extended_records key lookups in DataTypeBuilder so
UDTs with missing optional attributes (e.g. key 1) don't raise KeyError
- elements.py: fix tag name extraction to read the length-prefixed UTF-8
name from ext[0x01] rather than falling back to comp_name
- elements.py: add serial_number, comm_path, sfc_* fields to
ControllerBuilder using correct extended-record attribute offsets
- elements.py: handle cip_type high-byte flags (e.g. 0x8069) in
MapDeviceBuilder so all module types are parsed correctly
- elements.py: fix mismatched member_count vs children list iteration in
DataTypeBuilder to avoid IndexError on some UDT layouts
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- api.py: add ConvertAcdToL5x class that parses an ACD file and writes a pretty-printed (or compact) L5X XML file importable by Studio 5000; uses the existing RSLogix5000Content.to_xml() serialisation - README: rewrite with comprehensive usage examples covering tags, programs/routines/rungs, UDTs, AOIs, hardware modules, low-level SQLite access, and the new ACD-to-L5X conversion Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Owner
|
Looks great :) |
This was referenced Mar 27, 2026
Closed
Open
Open
jpect
added a commit
to jpect/acd
that referenced
this pull request
Mar 27, 2026
The DataTypeBuilder and TagBuilder improvements in PR hutcheb#18 correctly changed the iteration order of data_types and the resolved names/indices of tags. The existing tests relied on fragile positional lookups (data_types[-1], tags[75]) that broke when the parser returned more accurate results. Replace with name-based lookups: - test_parse_datatypes_dat: find STRING20 by name, then find DATA member by name - test_parse_tags_dat: find the Toggle tag by name, assert data_type == BOOL This is strictly better test design — positional assertions are brittle and provide no signal about which element was actually found. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
jpect
added a commit
to jpect/acd
that referenced
this pull request
Mar 27, 2026
The DataTypeBuilder and TagBuilder improvements in PR hutcheb#18 correctly changed the iteration order of data_types and the resolved names/indices of tags. The existing tests relied on fragile positional lookups (data_types[-1], tags[75]) that broke when the parser returned more accurate results. Replace with name-based lookups: - test_parse_datatypes_dat: find STRING20 by name, then find DATA member by name - test_parse_tags_dat: find the Toggle tag by name, assert data_type == BOOL This is strictly better test design — positional assertions are brittle and provide no signal about which element was actually found. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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
This PR fixes several bugs encountered when parsing real-world ACD files and adds the long-requested ACD-to-L5X conversion feature.
Bug fixes
acd/generated/comments/fafa_coments.pyerrors="replace"to all.decode("UTF-8")calls — fixesUnicodeDecodeErrorwhen controller comments contain non-ASCII bytes (e.g. degree symbols, accented characters)acd/l5x/elements.pyDataTypeBuilder: guard extended_records key lookups to fixKeyErroron UDTs with missing optional attributesDataTypeBuilder: fix member iteration to use actual children list length rather thanmember_countfield — preventsIndexErroron mismatched layoutsTagBuilder: read tag name from length-prefixed UTF-8 field inext[0x01]correctlyControllerBuilder: extractserial_number,comm_path, and SFC fields using correct extended-record attribute offsetsMapDeviceBuilder: handlecip_typehigh-byte flags (e.g.0x8069) so all module types are parsed without silently returning empty MapDevice objectsNew feature — ACD to L5X conversion
acd/api.pyConvertAcdToL5xclass — parses an ACD file and writes a valid L5X XML file importable by Studio 5000 Logix Designerpretty_print=Falsefor compact outputREADME
Tested against