Skip to main content

UdsServer

Struct UdsServer 

Source
pub struct UdsServer<H, S>{ /* private fields */ }
Expand description

Stateful UDS ECU server state machine.

Receives raw UDS frames via [handle], uses UdsFrameExt for protocol-level decisions (SID dispatch, suppress bit, sub-function), and decodes typed messages only where structured field access is needed.

All timing is driven by [tick] - no blocking, no hardware timers, no OS calls. Suitable for direct use as a SimNode in ace-sim.

Implementations§

Source§

impl<H, S> UdsServer<H, S>

Source

pub fn new( config: ServerConfig, handler: H, security_provider: S, address: NodeAddress, ) -> Self

Source

pub fn address(&self) -> &NodeAddress

Source

pub fn session_type(&self) -> u8

Source

pub fn security_level(&self) -> u8

Source

pub fn handle( &mut self, src: &NodeAddress, data: &[u8], now: Instant, ) -> Result<(), ServerError<H::Error>>

Receives a raw UDS frame from src.

Wraps the bytes in a UdsFrame and uses UdsFrameExt for protocol-level decisions before dispatching to service handlers. Typed message decode via to_message() is deferred to individual handlers that need structured field access.

Source

pub fn tick(&mut self, now: Instant) -> Result<(), ServerError<H::Error>>

Advances internal timers - S3 watchdog and periodic DID scheduling.

Source

pub fn drain_outbox( &mut self, out: &mut Vec<(NodeAddress, Vec<u8, MAX_FRAME>), MAX_OUTBOX>, ) -> usize

Drains pending outbound frames into out.

Trait Implementations§

Source§

impl<H, S> Debug for UdsServer<H, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<H, S> SimNode<MAX_FRAME, MAX_OUTBOX> for UdsServer<H, S>

Source§

fn handle( &mut self, src: &NodeAddress, data: &[u8], now: Instant, ) -> Result<(), Self::Error>

Delivers a raw UDS frame to the server.

The SimRunner calls this after the SimBus delivers a message. Errors are returned to the runner - in simulation these are observed and recorded. In production the transport layer decides whether to reset or continue.

Source§

fn tick(&mut self, now: Instant) -> Result<(), Self::Error>

Advances internal timers.

Called by the SimRunner on every tick regardless of whether any messages were delivered. Drives the S3 watchdog and periodic DID scheduling.

Source§

fn drain_outbox( &mut self, out: &mut Vec<(NodeAddress, Vec<u8, MAX_FRAME>), MAX_OUTBOX>, ) -> usize

Drains pending outbound frames into out.

The SimRunner collects these after every handle and tick call and routes them back onto the SimBus.

Source§

type Error = ServerError<<H as ServerHandler>::Error>

Source§

fn address(&self) -> &NodeAddress

Returns this node’s address on the simulation bus.

Auto Trait Implementations§

§

impl<H, S> Freeze for UdsServer<H, S>
where H: Freeze, S: Freeze,

§

impl<H, S> RefUnwindSafe for UdsServer<H, S>

§

impl<H, S> Send for UdsServer<H, S>
where H: Send, S: Send,

§

impl<H, S> Sync for UdsServer<H, S>
where H: Sync, S: Sync,

§

impl<H, S> Unpin for UdsServer<H, S>
where H: Unpin, S: Unpin,

§

impl<H, S> UnsafeUnpin for UdsServer<H, S>
where H: UnsafeUnpin, S: UnsafeUnpin,

§

impl<H, S> UnwindSafe for UdsServer<H, S>
where H: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.