fix(cdd): rebuild CDD import on cddtools, read field values correctly (#422) - #434
Merged
Merged
Conversation
- read a field value "(a,b,c)" as its elements, not as one number, which aborted the import of any document that has one - replace cdd_tester_parser/cdd_parser_base/cdd_shared with the vendored cddtools package
- CddTools-doip.cdd: a template-derived document with CAN and DoIP both supported, replacing the hand-written fixtures - assert the variant x interface split, CAN and DoIP addressing, the 96 services over 20 SIDs, subfunction locking and DID member expansion
Collaborator
|
Not in this PR |
Contributor
Author
我先看看还有没有其他ODX/PDX解析问题,下一个PR修复。 |
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.
Fixes the CDD half of #422.
The bug
Importing a tester from a CDD died with
could not convert string to float: '0,0,0,0,0,0'.A data type can be a field (array):
CVALUETYPE@blis then the width of one element,minsz/maxszthe element count ("Bit Length / Field Size" in the CANdelaStudio help). A value of such a type lists one entry per element, in CANdela's list notation(0,0,0,0,0,0)— the same notation the document uses forlanguages='(en-US,zh-HANS)'ormayBeExec='(1,2,3,4,5)'. So any attribute value can be a list, and reading one as a single number aborted the whole document.The old parser hit it in
_load_choices(a text table over a field type). It was not the only unguarded spot, which is why this replaces the numeric handling wholesale rather than patching one call site.What changed
resources/cdd/cdd_tester_parser.py,cdd_parser_base.pyandcdd_shared.py(~2600 lines, the second and third being near-duplicates of each other) are replaced by the vendored cddtools package underresources/cdd/cddtools/.cddparse.pyis now a thin CLI shim. The package is pure stdlib, so nothing changes for the build; provenance and re-sync steps are inresources/cdd/cddtools/README.md.Every CDD attribute value now goes through one decoder that returns either a scalar or the element list, folding elements big-endian by element width, and never lets a raw string reach
int()/float().Behaviour
Same testers, same service ids, same service count and names, same CAN addresses and UDS timing as before on the same document. Deliberate differences:
SessionParameterRecord ARRAY 32→P2 NUM 16+P2Ex NUM 16)PowerDownTimeon 0x11,Security Access Data Recordon 0x27)SecuritySeedwas 16 bits where the data type says 32, and 0x28EnableRxAndEnableTxlost its0x00subfunction because it is markedspec="accm", notspec="sub"Tests
test/cdd/fixtures/CddTools-doip.cddreplaces the two hand-written fixtures — neither was a document CANdelaStudio could write. It is a template-derived document saved out of CANdelaStudio with CAN and DoIP both declared as supported, which covers what a synthetic file cannot: the variant x interface split, DoIP addressing, 96 services over 20 SIDs, subfunction locking, DID member expansion and an ASCII field parameter.npm run test -- test/cdd8/8,npm run typecheckclean.Not in this PR
The PDX/ODX half of #422 (
invalid literal for int() with base 16: '0x') is untouched: odxtools readsA_BYTEFIELDtwo hex characters at a time, so a value written0x1A2Bmakes the first pair0x. That needs a separate patch inresources/odx/odxparse.py.