ace_client/config.rs
1// region: Imports
2
3use ace_sim::clock::Duration;
4
5// endregion: Imports
6
7// region: Client Config
8
9/// Configuration for a UDS tester client.
10///
11/// Controls timing behaviour only - the client tracks no session or security state. All session
12/// and security management is the responsibility of the caller.
13#[derive(Debug, Clone)]
14pub struct ClientConfig {
15 /// P2 client - time to wait for a response before declaring timeout. Should match or slightly
16 /// exceed the server's P2 server timing.
17 pub p2_timeout: Duration,
18
19 /// P2* client - extended timeout after receiving a 0x78 Response Pending. Should match or
20 /// slightly exceed the server's P2* server timing.
21 pub p2_extended_timeout: Duration,
22
23 /// Physical address of this client node.
24 pub physical_address: u16,
25
26 /// Physical address of the target server.
27 pub target_address: u16,
28}
29
30impl ClientConfig {
31 pub fn new(physical_address: u16, target_address: u16) -> Self {
32 Self {
33 p2_timeout: Duration::from_millis(150),
34 p2_extended_timeout: Duration::from_millis(5_000),
35 physical_address,
36 target_address,
37 }
38 }
39
40 pub fn with_p2_timeout(mut self, timeout: Duration) -> Self {
41 self.p2_timeout = timeout;
42 self
43 }
44
45 pub fn with_p2_extended_timeout(mut self, timeout: Duration) -> Self {
46 self.p2_extended_timeout = timeout;
47 self
48 }
49}
50
51// endregion: Client Config