Expand description
Unified platform abstraction traits for nros.
This crate defines the backend-agnostic interface that platform
implementations (POSIX, Zephyr, FreeRTOS, bare-metal, etc.) must satisfy.
RMW backends consume these traits via thin shim crates that translate
RMW-specific C symbols (e.g., z_clock_now, uxr_millis) into calls
on the active platform implementation.
§Trait hierarchy
Capabilities are split into independent sub-traits so each RMW backend can declare exactly what it needs:
PlatformClock— monotonic clock (required by all backends)PlatformAlloc— heap allocation (zenoh-pico only)PlatformSleep— sleep / delay (zenoh-pico only)PlatformYield— cooperative yield (zenoh-picosocket_wait_event)PlatformRandom— pseudo-random number generation (zenoh-pico only)PlatformTime— wall-clock time (zenoh-pico only)PlatformThreading— tasks, mutexes, condvars (multi-threaded platforms)
§Compile-time resolution
Exactly one platform feature must be enabled. The ConcretePlatform
type alias (gated on any platform-* feature) resolves to the active
backend, eliminating generic parameters.
Modules§
- wake
- Phase 130 — ergonomic Rust wrapper around
PlatformThreading’s wake primitive. - xorshift32
- Xorshift32 PRNG helpers shared by RTOS platform crates that lack a hardware RNG.
Structs§
- Deploy
Overlay - Deploy-metadata overlay threaded from
nros::main!()into the board’s boot config (issue #48 cause 1). - Null
Node Runtime - No-op
NodeDispatchRuntimefor tests / placeholders. Every call returnsErr(())so callers that depend on a populated runtime fail loud rather than silently no-op. - Runtime
Ctx - Runtime context handed to
BoardEntry::run(setup). - Signaled
Callback - Layer-clean substitute for
nros::node_metadata::CallbackId+nros::node::CallbackCtxat theNodeDispatchRuntimeboundary (Phase 216.A.2).nros-platformsits belownrosin the dep graph, so the trait surface cannot reference those types directly. Thenros-side runtime impl wraps a real(CallbackId, &mut CallbackCtx)pair into this opaque shape before invokingNodeDispatchRuntime::signal_callback; the concrete dispatcher castsctx_ptrback to&mut nros::CallbackCtx<'_>at the call site. - Tier
Spec - One scheduling tier: an RTOS task running an
Executorover the shared session, admitting only the listed callback groups. - Wake
- RAII wrapper around the platform’s wake primitive.
Enums§
- Dispatch
Strategy - How a Node expects its callbacks to fire.
- Network
Error - Network bringup failure mode (matches the coarse shape of
[
super::transport::TransportError]). - Runtime
Error - Error returned by the codegen-emitted
run_plan(runtime)body (Phase 212.N.4) and by Node pkgregister(runtime)wrappers (Phase 212.N.7 step-2). - Sched
Error - Errors returned by
PlatformSchedulerentry points. - Sched
Policy - Per-thread OS scheduling policy.
- Timer
Error - Errors returned by
PlatformTimerentry points. - Wake
Init Error - Errors at construction time.
- Wake
Reason - Reason
wait_msreturned.
Constants§
- NET_
ENDPOINT_ ALIGN - NET_
ENDPOINT_ SIZE - NET_
SOCKET_ ALIGN - NET_
SOCKET_ SIZE - WAKE_
STORAGE_ ALIGN - Alignment of the inline storage buffer. Wide enough for every pointer-aligned primitive on 64-bit hosts.
- WAKE_
STORAGE_ BYTES - Maximum bytes the wake primitive may occupy on any supported
platform. Sized generously so we never have to bump for a new
RTOS port. Asserted against the runtime probe in
Wake::new.
Traits§
- Board
- Super-trait every board impl carries (mirrors
nros-board-common::board_init::Board). - Board
Config - Universal board configuration accessors.
- Board
Entry - Per-board boot driver.
- Board
Exit - Per-board termination contract.
- Board
Init - Per-board hardware-init contract.
- Board
Print - Per-board stdout contract.
- Board
Transport Config - Phase 173.5 — mutable transport knobs the orchestration generator
writes into a board
Configfromnros.toml[[transport]](theNanoRosOwnednet-stack path: the board owns smoltcp/lwIP/NetX, so the IP / baud value lands in the boardConfigrather than an RTOS config fragment). - Embassy
Board Entry - Board-side hook for Embassy integration (Phase 216.C.1).
- Network
Wait - Carrier / DHCP / link-up gate for IP-aware transports.
- Node
Dispatch Runtime - Node runtime sink the codegen-emitted
run_plan(runtime)body talks to (Phase 212.N.7 step-3.1). - Node
Runtime - Phase 214.K.1 — backward-compat alias. The board-side dispatch
sink was renamed
NodeRuntime→NodeDispatchRuntimeto disambiguate from the user-facingnros::NodeRuntimemetadata trait. This alias stays for one release cycle so external impl callers (per-board crates outside the tree) get a clear deprecation arrow rather than a hard break. Node runtime sink the codegen-emittedrun_plan(runtime)body talks to (Phase 212.N.7 step-3.1). - Platform
Alloc - Heap memory allocation.
- Platform
Clock - Monotonic clock.
- Platform
Critical Section - Global mutual exclusion against preemption + ISR delivery (Phase 121.9).
- Platform
Ivc - Inter-processor mailbox transport, modelled after NVIDIA Tegra IVC.
- Platform
Libc - Standard C library functions needed by zenoh-pico on bare-metal targets.
- Platform
Log - Per-platform leveled log delivery.
- Platform
Network Poll - Network poll callback for bare-metal platforms using smoltcp.
- Platform
Random - Pseudo-random number generation.
- Platform
Scheduler - Platform
Serial - Serial (byte-stream) transport.
- Platform
Sleep - Sleep primitives.
- Platform
Socket Helpers - Socket helper operations called by zenoh-pico’s transport layer.
- Platform
Tcp - TCP networking.
- Platform
Threading - Threading primitives: tasks, mutexes, and condition variables.
- Platform
Time - Wall-clock / system time.
- Platform
Timer - Periodic timer for ISR-driven sporadic-server budget refill
(Phase 110.E.b). The trait factors out the per-platform timer
surface so the executor (
nros-node) can register an atomic refill callback without becoming generic over the platform — seedocs/design/0017-platform-timer.md. - Platform
Udp - UDP unicast networking.
- Platform
UdpMulticast - UDP multicast networking (used for zenoh scouting on desktop platforms).
- Platform
Yield - Scheduler yield primitive.
- Rtic
Board Entry - Board-side hook for RTIC integration. The
nros::main!()proc-macro (216.B.3) generates a#[rtic::app]module that callsSelf::init_hardwarefrom inside the framework-generated#[init]body and wires the returned pair into RTIC#[local]storage. - Transport
Bringup - Per-board transport bringup contract.
Functions§
- freertos_
priority_ for - FreeRTOS native priority (0..=
configMAX_PRIORITIES-1, here 0–7) for a normalized 0–31 priority. RFC-0016 §Design: linear interpolation(n*7 + 15) / 31(round-to-nearest), so 0→0 (idle) and 31→7 (highest). Higher number = higher priority on FreeRTOS. - posix_
nice_ for - POSIX
nicevalue (-20..=19, lower = more CPU) for a normalized 0–31 priority. Best-effort: native preemption normally uses the default scheduler (strict ordering needsSCHED_FIFO+ privileges), so this is an advisory niceness, linear over the scale and clamped, with idle (0) pinned to the maximum19. Anchors track the RFC-0016 table (12→0 normal, 31→-20 critical). - threadx_
priority_ for - ThreadX native priority (0..=31, lower = higher priority) for a
normalized 0–31 priority. RFC-0016: inverted scale
31 - n, so the normalized idle (0) maps to ThreadX 31 (lowest) and normalized critical (31) maps to ThreadX 0 (highest).