Skip to main content

docan_rs/client/service/
ctrl_dtc_setting.rs

1//! response of Service 85
2
3use crate::{client::DoCanClient, DoCanResult};
4use iso14229_1::{DTCSettingType, Service, SUPPRESS_POSITIVE};
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 control_dtc_setting(
16        &mut self,
17        r#type: DTCSettingType,
18        parameter: Vec<u8>,
19        suppress_positive: bool,
20    ) -> DoCanResult<()> {
21        let service = Service::CtrlDTCSetting;
22        let mut sub_func = r#type.into();
23        if suppress_positive {
24            sub_func |= SUPPRESS_POSITIVE;
25        }
26        let cfg = self.context.get_cfg().await;
27        let request = Self::make_request(Service::CtrlDTCSetting, Some(sub_func), parameter, &cfg)?;
28
29        let _ = self
30            .suppress_positive_sr(
31                AddressType::Physical,
32                request,
33                suppress_positive,
34                Some((r#type.into(), service)),
35                &cfg,
36            )
37            .await?;
38
39        Ok(())
40    }
41}