Skip to content

fix(cdd): rebuild CDD import on cddtools, read field values correctly (#422) - #434

Merged
frankie-zeng merged 2 commits into
ecubus:masterfrom
crazy0104:fix/pdx-cdd-import-422
Aug 27, 2026
Merged

fix(cdd): rebuild CDD import on cddtools, read field values correctly (#422)#434
frankie-zeng merged 2 commits into
ecubus:masterfrom
crazy0104:fix/pdx-cdd-import-422

Conversation

@crazy0104

Copy link
Copy Markdown
Contributor

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@bl is then the width of one element, minsz/maxsz the 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 for languages='(en-US,zh-HANS)' or mayBeExec='(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.py and cdd_shared.py (~2600 lines, the second and third being near-duplicates of each other) are replaced by the vendored cddtools package under resources/cdd/cddtools/. cddparse.py is now a thin CLI shim. The package is pure stdlib, so nothing changes for the build; provenance and re-sync steps are in resources/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:

  • a payload container becomes its own parameters instead of one opaque byte array (SessionParameterRecord ARRAY 32P2 NUM 16 + P2Ex NUM 16)
  • a DID read expands into one parameter per DID member, each keeping its own name (the old parser emitted only the first member)
  • components the document declares but the old parser dropped now appear (PowerDownTime on 0x11, Security Access Data Record on 0x27)
  • two old defects fixed on the way: SecuritySeed was 16 bits where the data type says 32, and 0x28 EnableRxAndEnableTx lost its 0x00 subfunction because it is marked spec="accm", not spec="sub"

Tests

test/cdd/fixtures/CddTools-doip.cdd replaces 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/cdd 8/8, npm run typecheck clean.

Not in this PR

The PDX/ODX half of #422 (invalid literal for int() with base 16: '0x') is untouched: odxtools reads A_BYTEFIELD two hex characters at a time, so a value written 0x1A2B makes the first pair 0x. That needs a separate patch in resources/odx/odxparse.py.

- 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
@frankie-zeng
frankie-zeng merged commit c4cb7e3 into ecubus:master Aug 27, 2026
2 checks passed
@frankie-zeng

Copy link
Copy Markdown
Collaborator

Not in this PR
The PDX/ODX half of #422 (invalid literal for int() with base 16: '0x') is untouched: odxtools reads A_BYTEFIELD two hex characters at a time, so a value written 0x1A2B makes the first pair 0x. That needs a separate patch in resources/odx/odxparse.py. 这个是不是再来一个PR把他修复了

@crazy0104

Copy link
Copy Markdown
Contributor Author

Not in this PR The PDX/ODX half of #422 (invalid literal for int() with base 16: '0x') is untouched: odxtools reads A_BYTEFIELD two hex characters at a time, so a value written 0x1A2B makes the first pair 0x. That needs a separate patch in resources/odx/odxparse.py. 这个是不是再来一个PR把他修复了

我先看看还有没有其他ODX/PDX解析问题,下一个PR修复。

@crazy0104
crazy0104 deleted the fix/pdx-cdd-import-422 branch August 27, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants