1mod client_impl;
2mod context;
3
4pub use client_impl::*;
5
6use crate::{DoCanError, SecurityAlgo};
7use iso14229_1::{request, response, *};
8use iso15765_2::can::{Address, AddressType};
9use rs_can::CanResult;
10
11#[async_trait::async_trait]
12pub trait Client {
13 async fn update_address(&self, address: Address);
14 async fn update_security_algo(&self, algo: SecurityAlgo);
15 async fn add_data_identifier(&self, did: DataIdentifier, length: usize);
16 async fn remove_data_identifier(&self, did: DataIdentifier);
17 async fn session_ctrl(
27 &mut self,
28 r#type: SessionType,
29 suppress_positive: bool,
30 addr_type: AddressType,
31 ) -> CanResult<(), DoCanError>;
32 async fn ecu_reset(
33 &mut self,
34 r#type: ECUResetType,
35 suppress_positive: bool,
36 addr_type: AddressType,
37 ) -> CanResult<(), DoCanError>;
38 async fn security_access(
39 &mut self,
40 level: u8,
41 params: Vec<u8>,
42 ) -> CanResult<Vec<u8>, DoCanError>;
43 async fn unlock_security_access(
44 &mut self,
45 level: u8,
46 params: Vec<u8>,
47 salt: Vec<u8>,
48 ) -> CanResult<(), DoCanError>;
49 async fn communication_control(
50 &mut self,
51 ctrl_type: CommunicationCtrlType,
52 comm_type: CommunicationType,
53 node_id: Option<request::NodeId>,
54 suppress_positive: bool,
55 addr_type: AddressType,
56 ) -> CanResult<(), DoCanError>;
57 #[cfg(feature = "std2020")]
58 async fn authentication(
59 &mut self,
60 auth_task: AuthenticationTask,
61 data: request::Authentication,
62 ) -> CanResult<response::Authentication, DoCanError>;
63 async fn tester_present(
64 &mut self,
65 r#type: TesterPresentType,
66 suppress_positive: bool,
67 addr_type: AddressType,
68 ) -> CanResult<(), DoCanError>;
69 #[cfg(any(feature = "std2006", feature = "std2013"))]
70 async fn access_timing_parameter(
71 &mut self,
72 r#type: TimingParameterAccessType,
73 parameter: Vec<u8>,
74 suppress_positive: bool,
75 ) -> CanResult<Option<response::AccessTimingParameter>, DoCanError>;
76 async fn secured_data_transmit(
77 &mut self,
78 apar: AdministrativeParameter,
79 signature: SignatureEncryptionCalculation,
80 anti_replay_cnt: u16,
81 service: u8,
82 service_data: Vec<u8>,
83 signature_data: Vec<u8>,
84 ) -> CanResult<response::SecuredDataTrans, DoCanError>;
85 async fn control_dtc_setting(
86 &mut self,
87 r#type: DTCSettingType,
88 parameter: Vec<u8>,
89 suppress_positive: bool,
90 ) -> CanResult<(), DoCanError>;
91 async fn response_on_event(&mut self) -> CanResult<(), DoCanError>;
92 async fn link_control(
93 &mut self,
94 r#type: LinkCtrlType,
95 data: request::LinkCtrl,
96 suppress_positive: bool,
97 ) -> CanResult<(), DoCanError>;
98 async fn read_data_by_identifier(
99 &mut self,
100 did: DataIdentifier,
101 others: Vec<DataIdentifier>,
102 ) -> CanResult<response::ReadDID, DoCanError>;
103 async fn read_memory_by_address(
104 &mut self,
105 mem_loc: MemoryLocation,
106 ) -> CanResult<Vec<u8>, DoCanError>;
107 async fn read_scaling_data_by_identifier(
108 &mut self,
109 did: DataIdentifier,
110 ) -> CanResult<response::ReadScalingDID, DoCanError>;
111 async fn read_data_by_period_identifier(
113 &mut self,
114 mode: request::TransmissionMode,
115 did: Vec<u8>,
116 ) -> CanResult<response::ReadDataByPeriodId, DoCanError>;
117 async fn dynamically_define_data_by_identifier(
118 &mut self,
119 r#type: DefinitionType,
120 data: request::DynamicallyDefineDID,
121 suppress_positive: bool,
122 ) -> CanResult<Option<response::DynamicallyDefineDID>, DoCanError>;
123 async fn write_data_by_identifier(
124 &mut self,
125 did: DataIdentifier,
126 data: Vec<u8>,
127 ) -> CanResult<(), DoCanError>;
128 async fn write_memory_by_address(
129 &mut self,
130 alfi: AddressAndLengthFormatIdentifier,
131 mem_addr: u128,
132 mem_size: u128,
133 record: Vec<u8>,
134 ) -> CanResult<response::WriteMemByAddr, DoCanError>;
135 async fn clear_dtc_info(
137 &mut self,
138 group: utils::U24,
139 #[cfg(any(feature = "std2020"))] mem_sel: Option<u8>,
140 addr_type: AddressType,
141 ) -> CanResult<(), DoCanError>;
142 async fn read_dtc_info(
143 &mut self,
144 r#type: DTCReportType,
145 data: request::DTCInfo,
146 ) -> CanResult<response::DTCInfo, DoCanError>;
147 async fn io_control(
149 &mut self,
150 did: DataIdentifier,
151 param: IOCtrlParameter,
152 state: Vec<u8>,
153 mask: Vec<u8>,
154 ) -> CanResult<response::IOCtrl, DoCanError>;
155 async fn routine_control(
157 &mut self,
158 r#type: RoutineCtrlType,
159 routine_id: u16,
160 option_record: Vec<u8>,
161 ) -> CanResult<response::RoutineCtrl, DoCanError>;
162 async fn request_download(
164 &mut self,
165 alfi: AddressAndLengthFormatIdentifier,
166 mem_addr: u128,
167 mem_size: u128,
168 dfi: Option<DataFormatIdentifier>,
169 ) -> CanResult<response::RequestDownload, DoCanError>;
170 async fn request_upload(
171 &mut self,
172 alfi: AddressAndLengthFormatIdentifier,
173 mem_addr: u128,
174 mem_size: u128,
175 dfi: Option<DataFormatIdentifier>,
176 ) -> CanResult<response::RequestUpload, DoCanError>;
177 async fn transfer_data(
178 &mut self,
179 sequence: u8,
180 data: Vec<u8>,
181 ) -> CanResult<response::TransferData, DoCanError>;
182 async fn request_transfer_exit(&mut self, parameter: Vec<u8>)
183 -> CanResult<Vec<u8>, DoCanError>;
184 #[cfg(any(feature = "std2013", feature = "std2020"))]
185 async fn request_file_transfer(
186 &mut self,
187 operation: ModeOfOperation,
188 data: request::RequestFileTransfer,
189 ) -> CanResult<response::RequestFileTransfer, DoCanError>;
190}