pub trait PacketChannel<T: Packet>: Send + Sync {
    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

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

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

Writes a list of packets to the raw interface

Reads a list of packets from the raw interface

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.

Implementations on Foreign Types

Implementors