Skip to content

feat(uds_c): a UDS server over DoIP for C firmware, served from tables of handlers - #96

Draft
FelicianoAngulo2 wants to merge 2 commits into
feat/decline-listed-servicefrom
feat/uds-c-server
Draft

FelicianoAngulo2 wants to merge 2 commits into
feat/decline-listed-servicefrom
feat/uds-c-server

Conversation

@FelicianoAngulo2

@FelicianoAngulo2 FelicianoAngulo2 commented Oct 25, 2026 •

Copy link
Copy Markdown

The new uds_c crate embeds the uds_stack server in C firmware: the firmware lists its identifiers and handlers in C tables (uds_c.h), supplies non-blocking sockets and a clock, and polls the server from one task. Handlers answer through uds_record_copy, bounded by each identifier's table length, so C never writes server memory. uds_record_copy_16_be, _32_be and _64_be copy an integer big-endian, the byte order of UDS records. The governance tool admits the restated lint table that relaxes unsafe_code for this crate alone.

Depends on #95.

Issue URL

Towards https://github.com/luminartech/halo/issues/5100

Testing

Run on this branch with the commits of the PRs below it, each commit alone and on the stack's top:

  • tool self-tests, validate, governance, the Sphinx needs build, and prose (plain and CI's --strict crates/uds_c)
  • cargo test --workspace --all-features; clippy on the host and for thumbv7em-none-eabihf
  • just embedded builds on 1.91 for both targets and the size check (matches the baseline)
  • cargo doc with -D warnings; pre-commit run --all-files
  • On the stack's top also the uds_c Miri job from ci.yml and cargo package -p uds_c --no-verify

…s of handlers

The new crate holds everything a C firmware needs to serve UDS over DoIP from the stack, against the fixed C contract it ships as include/uds_c.h. UdsLayer and its tables mirror the header's structures, with the layouts asserted for 32-bit targets on both sides and compared field by field with the host's C compiler by a test. TableApp<P: Policy> implements every service uds_services stages over an ordered list of layers, the earlier entry winning, declines through serves those no layer has a handler for, so they are serviceNotSupported, and is built in a const context; the Policy states the layers, the sessions and their timing, the transition rule and the limits, and TableApp::validate refuses tables the server cannot serve safely. A handler answers through uds_record_copy into the record the server lends it while it runs, pends and is canceled through the operation-status protocol, and a reset or session change runs every layer's check and prepare before its response and every layer's execute, the last layer's first, from execute_deferred once the response is out. nal adapts the header's socket calls to edge-nal, cancel-safe; doip names the entity and transport over them, starts discovery and polls the server; the time-driver feature gives embassy-time's clock over uds_now_ms. The crate restates the lint standard with unsafe_code at deny and is not a default member, since it enables simple_doip's connection feature, so CI lints, tests, documents and packages it in its own job, packaging unverified until the APIs it calls are on crates.io, runs its tests under Miri, and builds it for both bare-metal targets at the MSRV. It depends on uds_on_ip, so it is published last and carries the release tag. The embedded probe is unchanged.
uds_record_copy_16_be, uds_record_copy_32_be and uds_record_copy_64_be copy a u16, u32 or u64 into the lent record at an offset, in big-endian order, the byte order of UDS records, bounded as uds_record_copy bounds a copy, so a C handler no longer packs the bytes itself; a float goes as its IEEE 754 bits. The test firmware's seed handler answers through uds_record_copy_16_be.

This branch has not been deployed

No deployments
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