mod client;
mod frame;
mod pci;
mod response;
mod services;
use automotive_diag::uds::{UdsCommand, UdsError};
pub use client::UdsClient;
pub use frame::*;
pub use pci::{PciByte, PciType};
pub use response::{Response, ResponseSlot};
pub use services::RealTimeType;
#[derive(Clone, Debug, thiserror::Error)]
pub enum DiagError {
#[error("Diagnostic server does not support the request")]
NotSupported,
#[error("ECU error: 0x{:02X} ({:?})", *code as u8, def)]
ECUError {
code: UdsError,
rsid: UdsCommand,
def: Option<String>,
},
#[error("ECU did not respond to the request")]
EmptyResponse,
#[error("ECU response is wrong command. Expected: {want}, received {received}")]
WrongMessage {
want: UdsCommand,
received: UdsCommand,
},
#[error("ECU response is wrong PCI type. Expected: {want:?}, received {received:?}")]
WrongPciType {
want: PciType,
received: PciType,
},
#[error("Diagnostic server was not running")]
ServerNotRunning,
#[error("ECU response size was not the correct length")]
InvalidResponseLength,
#[error("Diagnostic function parameter invalid")]
ParameterInvalid,
#[error("Diagnostic server hardware channel error")]
ChannelError,
#[error("Diagnostic server hardware error")]
HardwareError,
#[error("Diagnostic server feature is unimplemented: '{0}'")]
NotImplemented(String),
#[error(
"Requested Ident 0x{:04X?}, but received ident 0x{:04X?}",
want,
received
)]
MismatchedIdentResponse {
want: u16,
received: u16,
},
#[error("ECU server didn't response in time")]
Timeout,
#[error("Diag Frame Error: {error}")]
FrameError { error: FrameError },
#[error("Unkown Diagnostic Error")]
Others,
}