docan_rs/client/service/
io_ctrl.rs1use crate::{client::DoCanClient, DoCanError, DoCanResult};
4use iso14229_1::{request, response, DataIdentifier, IOCtrlParameter, Service};
5use iso15765_2::can::AddressType;
6use rs_can::{CanDevice, CanFrame};
7use std::{fmt::Display, hash::Hash};
8
9impl<D, C, F> DoCanClient<D, C, F>
10where
11 D: CanDevice<Channel = C, Frame = F> + Clone + Send + 'static,
12 C: Clone + Eq + Display + Hash + Send + Sync + 'static,
13 F: CanFrame<Channel = C> + Clone + Display + 'static,
14{
15 pub async fn io_control(
16 &mut self,
17 did: DataIdentifier,
18 param: IOCtrlParameter,
19 state: Vec<u8>,
20 mask: Vec<u8>,
21 ) -> DoCanResult<response::IOCtrl> {
22 let cfg = self.context.get_cfg().await;
23 let data = request::IOCtrl::new(did, param, state, mask, &cfg)
24 .map_err(DoCanError::Iso14229Error)?;
25 let request = Self::make_request(Service::IOCtrl, None, data, &cfg)?;
26
27 self.send_and_parse(AddressType::Physical, request, None, &cfg)
28 .await
29 }
30}