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 def: Option<String>,
26 },
27 #[error("ECU did not respond to the request")]
29 EmptyResponse,
30 #[error("ECU response is wrong command. Expected: {want}, received {received}")]
32 WrongMessage {
33 want: UdsCommand,
35 received: UdsCommand,
37 },
38 #[error("ECU response is wrong PCI type. Expected: {want:?}, received {received:?}")]
40 WrongPciType {
41 want: PciType,
43 received: PciType,
45 },
46 #[error("Diagnostic server was not running")]
48 ServerNotRunning,
49 #[error("ECU response size was not the correct length")]
51 InvalidResponseLength,
52 #[error("Diagnostic function parameter invalid")]
55 ParameterInvalid,
56 #[error("Diagnostic server hardware channel error")]
58 ChannelError,
59 #[error("Diagnostic server hardware error")]
61 HardwareError,
62 #[error("Diagnostic server feature is unimplemented: '{0}'")]
64 NotImplemented(String),
65 #[error(
67 "Requested Ident 0x{:04X?}, but received ident 0x{:04X?}",
68 want,
69 received
70 )]
71 MismatchedIdentResponse {
72 want: u16,
74 received: u16,
76 },
77 #[error("ECU server didn't response in time")]
79 Timeout,
80 #[error("Diag Frame Error: {error}")]
82 FrameError { error: FrameError },
83 #[error("Unkown Diagnostic Error")]
85 Others,
86}