pub trait PacketChannel<T: Packet>: Send + Sync {
    // Required methods
    fn open(&mut self) -> ChannelResult<()>;
    fn close(&mut self) -> ChannelResult<()>;
    fn write_packets(
        &mut self,
        packets: Vec<T>,
        timeout_ms: u32
    ) -> ChannelResult<()>;
    fn read_packets(
        &mut self,
        max: usize,
        timeout_ms: u32
    ) -> ChannelResult<Vec<T>>;
    fn clear_rx_buffer(&mut self) -> ChannelResult<()>;
    fn clear_tx_buffer(&mut self) -> ChannelResult<()>;
}
Expand description

A PacketChannel is a way for a device to send and receive individual network packets across an ECU network. Unlike PayloadChannel, this channel type is unfiltered, so all network traffic may be visible, and filtering should be done in software. Most of the protocols that implement PayloadChannel are actually higher-level PacketChannels which use multiple packets to send larger payloads. Such is the case with ISO-TP over CAN.

Required Methods§

source

fn open(&mut self) -> ChannelResult<()>

Opens the channel, from this point forward, the network filter will be applied to be fully open so data has to be polled rapidly to avoid a driver’s internal buffer from filling up rapidly

source

fn close(&mut self) -> ChannelResult<()>

Closes the channel. Once closed, no more traffic can be polled or written to the channel.

source

fn write_packets( &mut self, packets: Vec<T>, timeout_ms: u32 ) -> ChannelResult<()>

Writes a list of packets to the raw interface

source

fn read_packets(&mut self, max: usize, timeout_ms: u32) -> ChannelResult<Vec<T>>

Reads a list of packets from the raw interface

source

fn clear_rx_buffer(&mut self) -> ChannelResult<()>

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

source

fn clear_tx_buffer(&mut self) -> ChannelResult<()>

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

Implementations on Foreign Types§

source§

impl<X: Packet, T: PacketChannel<X> + ?Sized> PacketChannel<X> for Box<T>

source§

fn open(&mut self) -> ChannelResult<()>

source§

fn close(&mut self) -> ChannelResult<()>

source§

fn write_packets( &mut self, packets: Vec<X>, timeout_ms: u32 ) -> ChannelResult<()>

source§

fn read_packets(&mut self, max: usize, timeout_ms: u32) -> ChannelResult<Vec<X>>

source§

fn clear_rx_buffer(&mut self) -> ChannelResult<()>

source§

fn clear_tx_buffer(&mut self) -> ChannelResult<()>

source§

impl<X: Packet, T: PacketChannel<X> + ?Sized> PacketChannel<X> for Arc<Mutex<T>>

source§

fn open(&mut self) -> ChannelResult<()>

source§

fn close(&mut self) -> ChannelResult<()>

source§

fn write_packets( &mut self, packets: Vec<X>, timeout_ms: u32 ) -> ChannelResult<()>

source§

fn read_packets(&mut self, max: usize, timeout_ms: u32) -> ChannelResult<Vec<X>>

source§

fn clear_rx_buffer(&mut self) -> ChannelResult<()>

source§

fn clear_tx_buffer(&mut self) -> ChannelResult<()>

Implementors§