Trait ecu_diagnostics::channel::PacketChannel
source · [−]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
fn open(&mut self) -> ChannelResult<()>
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
fn close(&mut self) -> ChannelResult<()>
fn close(&mut self) -> ChannelResult<()>
Closes the channel. Once closed, no more traffic can be polled or written to the channel.
fn write_packets(
&mut self,
packets: Vec<T>,
timeout_ms: u32
) -> ChannelResult<()>
fn write_packets(
&mut self,
packets: Vec<T>,
timeout_ms: u32
) -> ChannelResult<()>
Writes a list of packets to the raw interface
fn read_packets(&mut self, max: usize, timeout_ms: u32) -> ChannelResult<Vec<T>>
fn read_packets(&mut self, max: usize, timeout_ms: u32) -> ChannelResult<Vec<T>>
Reads a list of packets from the raw interface
fn clear_rx_buffer(&mut self) -> ChannelResult<()>
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
fn clear_tx_buffer(&mut self) -> ChannelResult<()>
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.