8000 feat: expose selected CDD service catalogs by tomrford · Pull Request #57 · tomrford/gocan · GitHub
[go: up one dir, main page]

Skip to content

feat: expose selected CDD service catalogs - #57

Merged
tomrford merged 1 commit into
mainfrom
feat/cdd-service-catalog
Sep 5, 2026
Merged

tomrford merged 1 commit into
mainfrom
feat/cdd-service-catalog

Conversation

@tomrford
@tomrford tomrford commented Sep 5, 2026 •
Copy link
Copy Markdown
Owner

CDD parsing currently selects the first ECU/variant and exposes only DID records, so a consumer cannot browse the full diagnostic catalog or distinguish missing services from unsupported layouts. This change separates document parsing from catalog selection and preserves classes, standalone instances, and their services in source order. Unsupported entries remain visible with diagnostics.

Draft pending consumer integration validation.

API changes

  • Parse and ParseFile return a Document. Its ECUs expose variant choices; Document.Select(Selection{ECU: 1, Variant: 1}) resolves one catalog. Indexes are one-based. Zero selects automatically only when there is exactly one choice at that level. Variants are not merged.
  • Database.Entries preserves interleaved classes and standalone instances. Services own their source/template identities, literal requirements, request and positive-response metadata. Existing single-record codecs resolve independently for each service alternative.
  • DID lookups are views of the same service objects. DID.Read and DID.Write are service slices; their records are reached through PositiveResponse.Record and Request.Record. Repeated names or identifiers remain visible but make the corresponding lookup ambiguous.
  • Shared metadata retains qualifiers, language-tagged names/descriptions, inline text order, paragraph breaks, and field grouping. Display-language selection does not change codec keys or infer template text inheritance.
  • Diagnostics identify source paths and distinguish binding, message, codec, requirement, and DID lookup problems. Record.CodecError() exposes codec availability without attempting an encode/decode.

See cdd/example_test.go for a runnable selection, enumeration, and decoding example. The UDS DID lifecycle test uses the new API.

Literal state references retain the PR 55 contract: omitted states do not imply permission, and template rules/exclusions remain unresolved. Whole-message encoding, DTC semantics, and automatic session/security changes remain outside this change. DID views recognise the literal SID/identifier shape; they do not establish that an ECU uses UDS.

Validation

  • go test -race ./...
  • go vet ./...
  • gofmt -l .
  • git diff --check
  • Independent review completed; protocol failures no longer hide otherwise resolvable requirements, and SID failures are classified as message diagnostics.
  • Public cantools CDD examples expose all 12 and 32 service instances respectively, including standalone variant instances. Unsupported constructs remain visible with diagnostics. Generic fixtures cover selection, presentation, reference failures, distinct service layouts, codec isolation, and ambiguous lookups.

Note

Medium Risk
Breaking public cdd API and DID shape affects any consumer still calling Parse for a Database or encoding via did.Read/did.Write directly.

Overview
Breaking API: Parse / ParseFile now return a Document with ECU/variant choices; Document.Select builds a per-selection Database instead of always using the first ECU/variant.

The catalog is no longer “DID records only.” Database.Entries keeps classes, standalone instances, and services (protocol binding, REQ/POS parameters, per-service Requirements, transitions). Unsupported or broken services stay in the catalog with typed Diagnostics (path, source, kind). Duplicate XML ids are treated as ambiguous references rather than last-wins.

DIDs are views over matching read/write services: Read / Write are service slices; payloads use PositiveResponse.Record / Request.Record. Lookups by name or identifier fail when ambiguous, but all DIDs remain listed. Record codecs gain CodecError() and metadata (localized text, field grouping); preconditions move from records to services.

README and uds tests are updated for the two-step parse → select flow and the new record paths.

Reviewed by Cursor Bugbot for commit 1f221da. Configure here.

@tomrford
tomrford marked this pull request as ready for review September 5, 2026 18:27
@tomrford
tomrford merged commit 45f274e into main Sep 5, 2026
2 checks passed
@tomrford
tomrford deleted the feat/cdd-service-catalog branch September 5, 2026 18:33
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.

1 participant

0