1pub trait NrcError: Into<u8> + core::fmt::Debug {
10 fn general_reject() -> Self;
14
15 fn service_not_supported() -> Self;
17 fn sub_function_not_supported() -> Self;
19 fn incorrect_message_length_or_invalid_format() -> Self;
21
22 fn response_too_long() -> Self;
24
25 fn busy_repeat_request() -> Self;
27
28 fn conditions_not_correct() -> Self;
30 fn request_sequence_error() -> Self;
32
33 fn no_response_from_subnet_component() -> Self;
35
36 fn failure_prevents_execution_of_requested_action() -> Self;
38
39 fn request_out_of_range() -> Self;
41 fn security_access_denied() -> Self;
43 fn invalid_key() -> Self;
45 fn exceeded_number_of_attempts() -> Self;
47 fn required_time_delay_not_expired() -> Self;
49 fn upload_download_not_accepted() -> Self;
51 fn transfer_data_suspended() -> Self;
53 fn general_programming_failure() -> Self;
55 fn wrong_block_sequence_counter() -> Self;
57 fn response_pending() -> Self;
59 fn sub_function_not_supported_in_active_session() -> Self;
61 fn service_not_supported_in_active_session() -> Self;
63
64 fn rpm_too_high() -> Self;
66
67 fn rpm_too_low() -> Self;
69
70 fn engine_is_running() -> Self;
72
73 fn engine_is_not_running() -> Self;
75
76 fn engine_run_time_too_low() -> Self;
78
79 fn temperature_too_high() -> Self;
81
82 fn temperature_too_low() -> Self;
84
85 fn vehicle_speed_too_high() -> Self;
87
88 fn vehicle_speed_too_low() -> Self;
90
91 fn throttle_pedal_too_high() -> Self;
93
94 fn throttle_pedal_too_low() -> Self;
96
97 fn transmission_range_not_in_neutral() -> Self;
99
100 fn transmission_range_not_in_gear() -> Self;
102
103 fn brake_switches_not_closed() -> Self;
105
106 fn shifter_level_not_in_park() -> Self;
108
109 fn torque_converter_clutch_locked() -> Self;
111
112 fn voltage_too_high() -> Self;
114
115 fn voltage_too_low() -> Self;
117 }
119
120#[derive(Debug, Clone, PartialEq, Eq)]
129#[cfg_attr(feature = "defmt", derive(defmt::Format))]
130#[repr(u8)]
131pub enum BuiltinNrc {
132 GeneralReject = 0x10,
133 ServiceNotSupported = 0x11,
134 SubFunctionNotSupported = 0x12,
135 IncorrectMessageLengthOrInvalidFormat = 0x13,
136 ResponseTooLong = 0x14,
137 BusyRepeatRequest = 0x21,
138 ConditionsNotCorrect = 0x22,
139 RequestSequenceError = 0x24,
140 NoResponseFromSubnetComponent = 0x25,
141 FailurePreventsExecutionOfRequestedAction = 0x26,
142 RequestOutOfRange = 0x31,
143 SecurityAccessDenied = 0x33,
144 InvalidKey = 0x35,
145 ExceededNumberOfAttempts = 0x36,
146 RequiredTimeDelayNotExpired = 0x37,
147 UploadDownloadNotAccepted = 0x70,
148 TransferDataSuspended = 0x71,
149 GeneralProgrammingFailure = 0x72,
150 WrongBlockSequenceCounter = 0x73,
151 ResponsePending = 0x78,
152 SubFunctionNotSupportedInActiveSession = 0x7E,
153 ServiceNotSupportedInActiveSession = 0x7F,
154 RpmTooHigh = 0x81,
155 RpmTooLow = 0x82,
156 EngineIsRunning = 0x83,
157 EngineIsNotRunning = 0x84,
158 EngineRunTimeTooLow = 0x85,
159 TemperatureTooHigh = 0x86,
160 TemperatureTooLow = 0x87,
161 VehicleSpeedTooHigh = 0x88,
162 VehicleSpeedToLow = 0x89,
163 ThrottlePedalTooHigh = 0x8A,
164 ThrottlePedalTooLow = 0x8B,
165 TransmissionRangeNotInNeutral = 0x8C,
166 TransmissionRangeNotInGear = 0x8D,
167 BrakeSwitchesNotClosed = 0x8F,
168 ShifterLevelNotInPark = 0x90,
169 TorqueConverterClutchLocked = 0x91,
170 VoltageTooHigh = 0x92,
171 VoltageTooLow = 0x93
172}
173
174impl From<BuiltinNrc> for u8 {
175 fn from(n: BuiltinNrc) -> u8 {
176 n as u8
177 }
178}
179
180impl NrcError for BuiltinNrc {
181 fn general_reject() -> Self {
182 Self::GeneralReject
183 }
184
185 fn service_not_supported() -> Self {
186 Self::ServiceNotSupported
187 }
188 fn sub_function_not_supported() -> Self {
189 Self::SubFunctionNotSupported
190 }
191 fn incorrect_message_length_or_invalid_format() -> Self {
192 Self::IncorrectMessageLengthOrInvalidFormat
193 }
194
195 fn response_too_long() -> Self {
196 Self::ResponseTooLong
197 }
198
199 fn busy_repeat_request() -> Self {
200 Self::BusyRepeatRequest
201 }
202
203 fn conditions_not_correct() -> Self {
204 Self::ConditionsNotCorrect
205 }
206 fn request_sequence_error() -> Self {
207 Self::RequestSequenceError
208 }
209
210 fn no_response_from_subnet_component() -> Self { Self::NoResponseFromSubnetComponent }
211
212 fn failure_prevents_execution_of_requested_action() -> Self {
213 Self::FailurePreventsExecutionOfRequestedAction
214 }
215
216 fn request_out_of_range() -> Self {
217 Self::RequestOutOfRange
218 }
219 fn security_access_denied() -> Self {
220 Self::SecurityAccessDenied
221 }
222 fn invalid_key() -> Self {
223 Self::InvalidKey
224 }
225 fn exceeded_number_of_attempts() -> Self {
226 Self::ExceededNumberOfAttempts
227 }
228 fn required_time_delay_not_expired() -> Self {
229 Self::RequiredTimeDelayNotExpired
230 }
231 fn upload_download_not_accepted() -> Self {
232 Self::UploadDownloadNotAccepted
233 }
234 fn transfer_data_suspended() -> Self {
235 Self::TransferDataSuspended
236 }
237 fn general_programming_failure() -> Self {
238 Self::GeneralProgrammingFailure
239 }
240 fn wrong_block_sequence_counter() -> Self {
241 Self::WrongBlockSequenceCounter
242 }
243 fn response_pending() -> Self {
244 Self::ResponsePending
245 }
246 fn sub_function_not_supported_in_active_session() -> Self {
247 Self::SubFunctionNotSupportedInActiveSession
248 }
249 fn service_not_supported_in_active_session() -> Self {
250 Self::ServiceNotSupportedInActiveSession
251 }
252
253 fn rpm_too_high() -> Self {
254 Self::RpmTooHigh
255 }
256
257 fn rpm_too_low() -> Self {
258 Self::RpmTooLow
259 }
260
261 fn engine_is_running() -> Self {
262 Self::EngineIsRunning
263 }
264
265 fn engine_is_not_running() -> Self {
266 Self::EngineIsNotRunning
267 }
268
269 fn engine_run_time_too_low() -> Self {
270 Self::EngineRunTimeTooLow
271 }
272
273 fn temperature_too_high() -> Self {
274 Self::TemperatureTooHigh
275 }
276
277 fn temperature_too_low() -> Self {
278 Self::TemperatureTooLow
279 }
280
281 fn vehicle_speed_too_high() -> Self {
282 Self::VehicleSpeedTooHigh
283 }
284
285 fn vehicle_speed_too_low() -> Self {
286 Self::VehicleSpeedToLow
287 }
288
289 fn throttle_pedal_too_high() -> Self {
290 Self::ThrottlePedalTooHigh
291 }
292
293 fn throttle_pedal_too_low() -> Self {
294 Self::ThrottlePedalTooLow
295 }
296
297 fn transmission_range_not_in_neutral() -> Self {
298 Self::TransmissionRangeNotInNeutral
299 }
300
301 fn transmission_range_not_in_gear() -> Self {
302 Self::TransmissionRangeNotInGear
303 }
304
305 fn brake_switches_not_closed() -> Self {
306 Self::BrakeSwitchesNotClosed
307 }
308
309 fn shifter_level_not_in_park() -> Self {
310 Self::ShifterLevelNotInPark
311 }
312
313 fn torque_converter_clutch_locked() -> Self {
314 Self::TorqueConverterClutchLocked
315 }
316
317 fn voltage_too_high() -> Self {
318 Self::VoltageTooHigh
319 }
320
321 fn voltage_too_low() -> Self {
322 Self::VoltageTooLow
323 }
324}
325
326