emcyphal_driver/
lib.rs

1//! Emcyphal driver interface
2//!
3//! The crate provides an interface between CAN device driver and the Emcyphal stack.
4//! Limited scope facilitates compatibility across versions.
5//! Driver crates should depend on this crate. Emcyphal stack users should depend on
6//! the `emcyphal` crate instead.
7//!
8//! A `Link` encompasses three asynchronous channels:
9//! * `RxFilter` produces receiver filter updates
10//! * `Rx` consumes received frames
11//! * `Tx` produces frames for transmission
12//!
13//! Unlike other network stack implementations, Emcyphal relies on driver runners to pull
14//! and push data. This design works because the basic stack structures are channel-like,
15//! while common drivers need their own task to dispatch preempted frames. Thus, the inverse
16//! structure eliminates intermediate channels and redundant runners.
17//!
18//! A driver should be able to filter in message frames on specified subjects, though it may
19//! limit the number of simultaneous subscriptions. `RxFilter` provides a stream of subscription
20//! add and removal requests. Range removal requests simplify asynchronous cleanup:
21//! the node does not need to store all removed subjects but only mark a remaining neighbor.
22//!
23//! A driver should be able to filter in service frames with the specified destination, though
24//! it may limit the number of simultaneous destinations. The node is expected to set the filter
25//! to its own address. In properly configured Cyphal networks, there should not be many unexpected
26//! frames designated for the node address, so the stack does not need filters for service IDs.
27//! `RxFilter` provides a stream of subscription add and removal requests. Range removal requests
28//! were added for consistency.
29//!
30//! Though the `Rx` channel is asynchronous, a driver may expect only short-term blockage.
31//! Such design allows the node to use async mutex for better concurrency management.
32//! However, it should not be used to exert back-pressure on the driver.
33
34#![no_std]
35
36// This mod MUST go first, so that the others see its macros.
37pub(crate) mod fmt;
38
39pub mod frame;
40pub mod internal;
41pub mod link;
42
43pub mod time {
44    pub use embassy_time::{Duration, Instant};
45}