Skip to main content

UdsClient

Struct UdsClient 

Source
pub struct UdsClient<'a, T: CanSocketTx> { /* private fields */ }

Implementations§

Source§

impl<'a, T: CanSocketTx> UdsClient<'a, T>

Source

pub fn new(channel: T, id: u32, resp: &'a LazyLock<Arc<ResponseSlot>>) -> Self

Create a new UdsClient instance.

Takes a CAN socket channel channel, a 32-bit identifier id, and a reference to a ResponseSlot wrapped in Arc. The Id::Extended is used to create a unique identifier for the CAN frame.

Source

pub async fn send_command<P: Into<u8>, M: Into<u8>>( &mut self, pci: P, cmd: M, args: &[u8], ) -> Result<(), DiagError>

Send a command without expecting a response.

This function sends a command using ISO 15765-2 format, which includes PCI, CMD, and ARGS. The args are added to the frame and sent using the send_raw method.

Source

pub async fn send_frame(&mut self, frame: UdsFrame) -> Result<(), DiagError>

Send an UDS frame without expecting a response.

This function sends the given UdsFrame to the CAN bus using the send_raw method after converting the frame into a byte vector.

Source

pub async fn send_frame_with_response( &mut self, frame: UdsFrame, ) -> Result<UdsFrame, DiagError>

Send an UDS frame and wait for a response.

This function sends an UdsFrame to the CAN bus and waits for a response. If the response is valid (Response::Ok), it returns the response frame, otherwise returns the error contained in Response::Error.

Source

pub async fn send_command_with_response<P: Into<u8>, M: Into<u8>>( &mut self, pci: P, cmd: M, args: &[u8], ) -> Result<UdsFrame, DiagError>

Send a command with the response.

This function is similar to send_command but expects a response after sending the command. It returns the response frame (UdsFrame) if successful, or the error if something went wrong.

Source

pub async fn receive(&mut self) -> Response

Receive a frame from the UDS server.

This function waits for and receives a response from the UDS server using the ResponseSlot. It blocks until a response is available and returns the response.

Source§

impl<T: CanSocketTx> UdsClient<'_, T>

Source

pub async fn uds_reset_ecu(&mut self) -> Result<(), DiagError>

Service ID: 0x11 - ECU Reset Description: The function will request an ECU reset event.

Source§

impl<T: CanSocketTx> UdsClient<'_, T>

Source

pub async fn uds_real_time_data_slow(&mut self) -> Result<(), DiagError>

Service ID: 0x2A - Data Transmission Sub-ID: 0x01 Description: The function will request an Realtime data sent from ECU with slow rate.

Source

pub async fn uds_real_time_data_medium(&mut self) -> Result<(), DiagError>

Service ID: 0x2A - Data Transmission Sub-ID: 0x02 Description: The function will request an Realtime data sent from ECU with medium rate.

Source

pub async fn uds_real_time_data_fast(&mut self) -> Result<(), DiagError>

Service ID: 0x2A - Data Transmission Sub-ID: 0x03 Description: The function will request an Realtime data sent from ECU with fast rate.

Source

pub async fn uds_real_time_data_stop(&mut self) -> Result<(), DiagError>

Service ID: 0x2A - Data Transmission Sub-ID: 0x04 Description: The function will send a stop event for realtime data from ECU.

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for UdsClient<'a, T>

§

impl<'a, T> !UnwindSafe for UdsClient<'a, T>

§

impl<'a, T> Freeze for UdsClient<'a, T>
where T: Freeze,

§

impl<'a, T> Send for UdsClient<'a, T>
where T: Send,

§

impl<'a, T> Sync for UdsClient<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for UdsClient<'a, T>
where T: Unpin,

§

impl<'a, T> UnsafeUnpin for UdsClient<'a, T>
where T: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.