Trait ecu_diagnostics::channel::PayloadChannel[][src]

pub trait PayloadChannel: Send + Sync {
    fn open(&mut self) -> ChannelResult<()>;
fn close(&mut self) -> ChannelResult<()>;
fn set_ids(&mut self, send: u32, recv: u32) -> ChannelResult<()>;
fn read_bytes(&mut self, timeout_ms: u32) -> ChannelResult<Vec<u8>>;
fn write_bytes(
        &mut self,
        addr: u32,
        buffer: &[u8],
        timeout_ms: u32
    ) -> ChannelResult<()>;
fn clear_rx_buffer(&mut self) -> ChannelResult<()>;
fn clear_tx_buffer(&mut self) -> ChannelResult<()>; fn read_write_bytes(
        &mut self,
        addr: u32,
        buffer: &[u8],
        write_timeout_ms: u32,
        read_timeout_ms: u32
    ) -> ChannelResult<Vec<u8>> { ... } }
Expand description

A payload channel is a way for a device to have a bi-directional communication link with a specific ECU

Required methods

This function opens the interface. It is ONLY called after set_ids and any other configuration function

Closes and destroys the channel

Configures the diagnostic channel with specific IDs for configuring the diagnostic server

Parameters
  • send - Send ID (ECU will listen for data with this ID)
  • recv - Receiving ID (ECU will send data with this ID)

Attempts to read bytes from the channel.

The contents being read should not include any protocol related bytes, just the payload destined for the diagnostic application

Parameters
  • timeout_ms - Timeout for reading bytes. If a value of 0 is used, it instructs the channel to immediately return with whatever was in its receiving buffer

Attempts to write bytes to the channel.

The contents being sent will just be the raw payload being sent to the device, it is up to the implementor of this function to add related protocol bytes to the message where necessary.

Parameters
  • Target address of the message
  • buffer - The buffer of bytes to write to the channel
  • timeout_ms - Timeout for writing bytes. If a value of 0 is used, it tells the channel to write without checking if data was actually written.

Tells the channel to clear its Rx buffer. This means all pending messages to be read should be wiped from the devices queue, such that PayloadChannel::read_bytes does not read them

Tells the channel to clear its Tx buffer. This means all messages that are queued to be sent to the ECU should be wiped.

Provided methods

Attempts to write bytes to the channel, then listen for the channels response

Parameters
  • Target address of the message
  • buffer - The buffer of bytes to write to the channel as the request
  • write_timeout_ms - Timeout for writing bytes. If a value of 0 is used, it tells the channel to write without checking if data was actually written.
  • read_timeout_ms - Timeout for reading bytes. If a value of 0 is used, it instructs the channel to immediately return with whatever was in its receiving buffer

Implementations on Foreign Types

Implementors