Trait uavcan::transfer::TransferFrame [−][src]
pub trait TransferFrame { const MAX_DATA_LENGTH: usize; fn new(id: TransferFrameID) -> Self; fn id(&self) -> TransferFrameID; fn data(&self) -> &[u8]; fn data_as_mut(&mut self) -> &mut [u8]; fn set_data_length(&mut self, length: usize); fn tail_byte(&self) -> TailByte { ... } fn is_start_frame(&self) -> bool { ... } fn is_end_frame(&self) -> bool { ... } fn is_single_frame(&self) -> bool { ... } fn full_id(&self) -> FullTransferID { ... } }
TransferFrame
is a CAN like frame that can be sent over a network
For a frame to work it need to have a 28 bit ID, and a payload of at least 4 bytes. Guarantee that frames are delivered in order and correctness check is needed as well.
The uavcan protocol defines how this works with a CAN2.0B frame
Associated Constants
const MAX_DATA_LENGTH: usize
Maximum data length the transfer protocol supports.
Required Methods
fn new(id: TransferFrameID) -> Self
Create a new TransferFrame with id: id, and length 0.
Data length can be changed with set_data_length(&self)
.
Data can be changed with data_as_mut(&mut self)
.
fn id(&self) -> TransferFrameID
Returns the 28 bit ID of this TransferFrame.
When deciding which frame that will be transmitted, the ID is used to prioritze (lower ID means higher priority)
fn data(&self) -> &[u8]
Returns a slice with the data in this TransferFrame
Length can be found by checking the length
of this slice self.data().len()
fn data_as_mut(&mut self) -> &mut [u8]
Returns a mutable slice with the data in this TransferFrame use this method to set/change the data inside this TransferFrame
fn set_data_length(&mut self, length: usize)
Set the data length of this TransferFrame
Panics
set_data_lengt(&mut self, length: usize)
should panic if length > T::MAX_DATA_LENGTH
Provided Methods
fn tail_byte(&self) -> TailByte
Returns the tail byte of the TransferFrame assuming the current length
Panics
panics if self.data().len() == 0
as no tail_byte exists
fn is_start_frame(&self) -> bool
Checks the tail byte if this frame is a start frame and return the result
fn is_end_frame(&self) -> bool
Checks the tail byte if this frame is an end frame and return the result
fn is_single_frame(&self) -> bool
Checks the tail byte if this is both a start frame and an end frame and return the result
fn full_id(&self) -> FullTransferID
Returns the full ID of the frame (both Frame ID and transfer ID)
Panics
panics if self.data().len() == 0
as no tail_byte exists
Implementations on Foreign Types
impl TransferFrame for ExtendedDataFrame
[src]
impl TransferFrame for ExtendedDataFrame
const MAX_DATA_LENGTH: usize
fn new(id: TransferFrameID) -> Self
[src]
fn new(id: TransferFrameID) -> Self
fn set_data_length(&mut self, length: usize)
[src]
fn set_data_length(&mut self, length: usize)
fn data(&self) -> &[u8]
[src]
fn data(&self) -> &[u8]
fn data_as_mut(&mut self) -> &mut [u8]
[src]
fn data_as_mut(&mut self) -> &mut [u8]
fn id(&self) -> TransferFrameID
[src]
fn id(&self) -> TransferFrameID
fn tail_byte(&self) -> TailByte
[src]
fn tail_byte(&self) -> TailByte
fn is_start_frame(&self) -> bool
[src]
fn is_start_frame(&self) -> bool
fn is_end_frame(&self) -> bool
[src]
fn is_end_frame(&self) -> bool
fn is_single_frame(&self) -> bool
[src]
fn is_single_frame(&self) -> bool
fn full_id(&self) -> FullTransferID
[src]
fn full_id(&self) -> FullTransferID