iso14229_1/common/
routine_ctrl.rs1use crate::{constant::ISO_SAE_RESERVED, error::Error, Service, utils};
5use crate::enum_to_vec;
6
7enum_to_vec! (
8 pub enum RoutineCtrlType {
9 StartRoutine = 1,
10 StopRoutine = 2,
11 RequestRoutineResults = 3,
12 }, u8);
13
14#[allow(non_upper_case_globals)]
15pub const TachographTestIds: RoutineId = RoutineId(0xE200);
16#[allow(non_upper_case_globals)]
17pub const EraseMemory: RoutineId = RoutineId(0xFF00);
18#[allow(non_upper_case_globals)]
19pub const CheckProgrammingDependencies: RoutineId = RoutineId(0xFF01);
20#[allow(non_upper_case_globals)]
21pub const EraseMirrorMemoryDTCs: RoutineId = RoutineId(0xFF02);
22
23#[derive(Debug, Copy, Clone, PartialEq, Eq)]
25pub struct RoutineId(pub u16);
26
27impl RoutineId {
28 #[inline]
29 pub fn name(&self) -> String {
30 match self.0 {
31 0x0000..=0x00FF => format!("{}(0x{:02X})", ISO_SAE_RESERVED, self.0),
32 0x0100..=0x01FF => format!("{}(0x{:02X})", "TachographTestIds", self.0),
33 0x0200..=0xDFFF => format!("{}(0x{:02X})", "VehicleManufacturerSpecific", self.0),
34 0xE000..=0xE1FF => format!("{}(0x{:02X})", "OBDTestIds", self.0),
35 0xE200 => format!("{}(0x{:02X})", "DeployLoopRoutineID", self.0),
36 0xE201..=0xE2FF => format!("{}(0x{:02X})", "SafetySystemRoutineIDs", self.0),
37 0xE300..=0xEFFF => format!("{}(0x{:02X})", ISO_SAE_RESERVED, self.0),
38 0xF000..=0xFEFF => format!("{}(0x{:02X})", "SystemSupplierSpecific", self.0),
39 0xFF00 => format!("{}(0x{:02X})", "EraseMemory", self.0),
40 0xFF01 => format!("{}(0x{:02X})", "CheckProgrammingDependencies", self.0),
41 0xFF02 => format!("{}(0x{:02X})", "EraseMirrorMemoryDTCs", self.0),
42 0xFF03..=0xFFFF => format!("{}(0x{:02X})", ISO_SAE_RESERVED, self.0),
43 }
45 }
46}
47
48impl From<u16> for RoutineId {
49 #[inline]
50 fn from(value: u16) -> Self {
51 Self(value)
52 }
53}
54
55impl Into<u16> for RoutineId {
56 #[inline]
57 fn into(self) -> u16 {
58 self.0
59 }
60}