pub struct UdsServer<const MAX_FRAME: usize, const MAX_OUTBOX: usize, const MAX_SESSIONS: usize, const MAX_SERVICES: usize, const MAX_DIDS: usize, const MAX_SECURITY_LEVELS: usize, const DEFAULT_S3: u64, const DEFAULT_P2: u64, const DEFAULT_P2_EXT: u64, const DEFAULT_LOCKOUT: u64, const DEFAULT_MAX_SECURITY_ATTEMPTS: u8, const MAX_SEED: usize, const MAX_PERIODIC: usize, H, S>where
H: ServerHandler,
S: SecurityProvider,{ /* 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<const MAX_FRAME: usize, const MAX_OUTBOX: usize, const MAX_SESSIONS: usize, const MAX_SERVICES: usize, const MAX_DIDS: usize, const MAX_SECURITY_LEVELS: usize, const DEFAULT_S3: u64, const DEFAULT_P2: u64, const DEFAULT_P2_EXT: u64, const DEFAULT_LOCKOUT: u64, const DEFAULT_MAX_SECURITY_ATTEMPTS: u8, const MAX_SEED: usize, const MAX_PERIODIC: usize, H, S> UdsServer<MAX_FRAME, MAX_OUTBOX, MAX_SESSIONS, MAX_SERVICES, MAX_DIDS, MAX_SECURITY_LEVELS, DEFAULT_S3, DEFAULT_P2, DEFAULT_P2_EXT, DEFAULT_LOCKOUT, DEFAULT_MAX_SECURITY_ATTEMPTS, MAX_SEED, MAX_PERIODIC, H, S>where
H: ServerHandler,
S: SecurityProvider,
impl<const MAX_FRAME: usize, const MAX_OUTBOX: usize, const MAX_SESSIONS: usize, const MAX_SERVICES: usize, const MAX_DIDS: usize, const MAX_SECURITY_LEVELS: usize, const DEFAULT_S3: u64, const DEFAULT_P2: u64, const DEFAULT_P2_EXT: u64, const DEFAULT_LOCKOUT: u64, const DEFAULT_MAX_SECURITY_ATTEMPTS: u8, const MAX_SEED: usize, const MAX_PERIODIC: usize, H, S> UdsServer<MAX_FRAME, MAX_OUTBOX, MAX_SESSIONS, MAX_SERVICES, MAX_DIDS, MAX_SECURITY_LEVELS, DEFAULT_S3, DEFAULT_P2, DEFAULT_P2_EXT, DEFAULT_LOCKOUT, DEFAULT_MAX_SECURITY_ATTEMPTS, MAX_SEED, MAX_PERIODIC, H, S>where
H: ServerHandler,
S: SecurityProvider,
pub fn new( config: ServerConfig<MAX_SESSIONS, MAX_SERVICES, MAX_DIDS, MAX_SECURITY_LEVELS>, handler: H, security_provider: S, address: NodeAddress, ) -> Self
pub fn address(&self) -> &NodeAddress
pub fn session_type(&self) -> u8
pub fn security_level(&self) -> u8
Sourcepub fn handle(
&mut self,
src: &NodeAddress,
data: &[u8],
now: Instant,
) -> Result<(), ServerError<H::Error>>
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.
Sourcepub fn tick(&mut self, now: Instant) -> Result<(), ServerError<H::Error>>
pub fn tick(&mut self, now: Instant) -> Result<(), ServerError<H::Error>>
Advances internal timers - S3 watchdog and periodic DID scheduling.
Sourcepub fn drain_outbox(
&mut self,
out: &mut Vec<(NodeAddress, Vec<u8, MAX_FRAME>), MAX_OUTBOX>,
) -> usize
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<const MAX_FRAME: usize, const MAX_OUTBOX: usize, const MAX_SESSIONS: usize, const MAX_SERVICES: usize, const MAX_DIDS: usize, const MAX_SECURITY_LEVELS: usize, const DEFAULT_S3: u64, const DEFAULT_P2: u64, const DEFAULT_P2_EXT: u64, const DEFAULT_LOCKOUT: u64, const DEFAULT_MAX_SECURITY_ATTEMPTS: u8, const MAX_SEED: usize, const MAX_PERIODIC: usize, H, S> Debug for UdsServer<MAX_FRAME, MAX_OUTBOX, MAX_SESSIONS, MAX_SERVICES, MAX_DIDS, MAX_SECURITY_LEVELS, DEFAULT_S3, DEFAULT_P2, DEFAULT_P2_EXT, DEFAULT_LOCKOUT, DEFAULT_MAX_SECURITY_ATTEMPTS, MAX_SEED, MAX_PERIODIC, H, S>
impl<const MAX_FRAME: usize, const MAX_OUTBOX: usize, const MAX_SESSIONS: usize, const MAX_SERVICES: usize, const MAX_DIDS: usize, const MAX_SECURITY_LEVELS: usize, const DEFAULT_S3: u64, const DEFAULT_P2: u64, const DEFAULT_P2_EXT: u64, const DEFAULT_LOCKOUT: u64, const DEFAULT_MAX_SECURITY_ATTEMPTS: u8, const MAX_SEED: usize, const MAX_PERIODIC: usize, H, S> Debug for UdsServer<MAX_FRAME, MAX_OUTBOX, MAX_SESSIONS, MAX_SERVICES, MAX_DIDS, MAX_SECURITY_LEVELS, DEFAULT_S3, DEFAULT_P2, DEFAULT_P2_EXT, DEFAULT_LOCKOUT, DEFAULT_MAX_SECURITY_ATTEMPTS, MAX_SEED, MAX_PERIODIC, H, S>
Source§impl<const MAX_FRAME: usize, const MAX_OUTBOX: usize, const MAX_SESSIONS: usize, const MAX_SERVICES: usize, const MAX_DIDS: usize, const MAX_SECURITY_LEVELS: usize, const DEFAULT_S3: u64, const DEFAULT_P2: u64, const DEFAULT_P2_EXT: u64, const DEFAULT_LOCKOUT: u64, const DEFAULT_MAX_SECURITY_ATTEMPTS: u8, const MAX_SEED: usize, const MAX_PERIODIC: usize, H, S> SimNode<MAX_FRAME, MAX_OUTBOX> for UdsServer<MAX_FRAME, MAX_OUTBOX, MAX_SESSIONS, MAX_SERVICES, MAX_DIDS, MAX_SECURITY_LEVELS, DEFAULT_S3, DEFAULT_P2, DEFAULT_P2_EXT, DEFAULT_LOCKOUT, DEFAULT_MAX_SECURITY_ATTEMPTS, MAX_SEED, MAX_PERIODIC, H, S>where
H: ServerHandler,
S: SecurityProvider,
impl<const MAX_FRAME: usize, const MAX_OUTBOX: usize, const MAX_SESSIONS: usize, const MAX_SERVICES: usize, const MAX_DIDS: usize, const MAX_SECURITY_LEVELS: usize, const DEFAULT_S3: u64, const DEFAULT_P2: u64, const DEFAULT_P2_EXT: u64, const DEFAULT_LOCKOUT: u64, const DEFAULT_MAX_SECURITY_ATTEMPTS: u8, const MAX_SEED: usize, const MAX_PERIODIC: usize, H, S> SimNode<MAX_FRAME, MAX_OUTBOX> for UdsServer<MAX_FRAME, MAX_OUTBOX, MAX_SESSIONS, MAX_SERVICES, MAX_DIDS, MAX_SECURITY_LEVELS, DEFAULT_S3, DEFAULT_P2, DEFAULT_P2_EXT, DEFAULT_LOCKOUT, DEFAULT_MAX_SECURITY_ATTEMPTS, MAX_SEED, MAX_PERIODIC, H, S>where
H: ServerHandler,
S: SecurityProvider,
Source§fn handle(
&mut self,
src: &NodeAddress,
data: &[u8],
now: Instant,
) -> Result<(), Self::Error>
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>
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
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.