docan_rs/client/service/
routine_ctrl.rs1use iso14229_1::{request, response, RoutineCtrlType, RoutineId, Service};
4use iso15765_2::can::AddressType;
5use rs_can::{CanDevice, CanFrame};
6use std::{fmt::Display, hash::Hash};
7
8use crate::{DoCanClient, DoCanResult};
9
10impl<D, C, F> DoCanClient<D, C, F>
11where
12 D: CanDevice<Channel = C, Frame = F> + Clone + Send + 'static,
13 C: Clone + Eq + Display + Hash + Send + Sync + 'static,
14 F: CanFrame<Channel = C> + Clone + Display + 'static,
15{
16 pub async fn routine_control(
17 &mut self,
18 r#type: RoutineCtrlType,
19 routine_id: u16,
20 option_record: Vec<u8>,
21 ) -> DoCanResult<response::RoutineCtrl> {
22 let service = Service::RoutineCtrl;
23 let data = request::RoutineCtrl {
24 routine_id: RoutineId(routine_id),
25 option_record,
26 };
27 let cfg = self.context.get_cfg().await;
28 let request = Self::make_request(service, Some(r#type.into()), data, &cfg)?;
29
30 self.send_and_parse(
31 AddressType::Physical,
32 request,
33 Some((r#type.into(), service)),
34 &cfg,
35 )
36 .await
37 }
38}