Skip to main content

docan_rs/client/service/
read_mem_by_addr.rs

1//! response of Service 23
2
3use crate::{client::DoCanClient, DoCanResult};
4use iso14229_1::{request, MemoryLocation, 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 read_memory_by_address(
16        &mut self,
17        mem_loc: MemoryLocation,
18    ) -> DoCanResult<Vec<u8>> {
19        let data = request::ReadMemByAddr(mem_loc);
20        let cfg = self.context.get_cfg().await;
21        let request = Self::make_request(Service::ReadMemByAddr, None, data, &cfg)?;
22
23        let response = self
24            .send_and_response(AddressType::Physical, request, None, &cfg)
25            .await?;
26
27        Ok(response.raw_data().to_vec())
28    }
29}