uds_client/uds_client/
mod.rs1mod client;
2mod frame;
3mod pci;
4mod response;
5mod services;
6
7use automotive_diag::uds::{UdsCommand, UdsError};
8pub use client::UdsClient;
9pub use frame::*;
10pub use pci::{PciByte, PciType};
11pub use response::{Response, ResponseSlot};
12pub use services::RealTimeType;
13
14#[derive(Clone, Debug, thiserror::Error)]
15pub enum DiagError {
17 #[error("Diagnostic server does not support the request")]
18 NotSupported,
19 #[error("ECU error: 0x{:02X} ({:?})", *code as u8, def)]
21 ECUError {
22 code: UdsError,
24 rsid: UdsCommand,
26 def: Option<String>,
28 },
29 #[error("ECU did not respond to the request")]
31 EmptyResponse,
32 #[error("ECU response is wrong command. Expected: {want}, received {received}")]
34 WrongMessage {
35 want: UdsCommand,
37 received: UdsCommand,
39 },
40 #[error("ECU response is wrong PCI type. Expected: {want:?}, received {received:?}")]
42 WrongPciType {
43 want: PciType,
45 received: PciType,
47 },
48 #[error("Diagnostic server was not running")]
50 ServerNotRunning,
51 #[error("ECU response size was not the correct length")]
53 InvalidResponseLength,
54 #[error("Diagnostic function parameter invalid")]
57 ParameterInvalid,
58 #[error("Diagnostic server hardware channel error")]
60 ChannelError,
61 #[error("Diagnostic server hardware error")]
63 HardwareError,
64 #[error("Diagnostic server feature is unimplemented: '{0}'")]
66 NotImplemented(String),
67 #[error(
69 "Requested Ident 0x{:04X?}, but received ident 0x{:04X?}",
70 want,
71 received
72 )]
73 MismatchedIdentResponse {
74 want: u16,
76 received: u16,
78 },
79 #[error("ECU server didn't response in time")]
81 Timeout,
82 #[error("Diag Frame Error: {error}")]
84 FrameError { error: FrameError },
85 #[error("Unkown Diagnostic Error")]
87 Others,
88}