Frame

Struct Frame 

Source
pub struct Frame {
    pub not_error_flag: bool,
    pub start_frame_flag: bool,
    pub multi_frame_flag: bool,
    pub frame_id: FrameId,
    pub device_address: u16,
    pub data_len: u8,
    pub data: [u8; 8],
}
Expand description

Ross compatible representation of a CAN frame

Fields§

§not_error_flag: bool

If this bit is low, the frame is considered to be an error frame

§start_frame_flag: bool

If this bit is high, the frame is considered to be the first frame of a packet

§multi_frame_flag: bool

If this bit is high, the frame is considered to be only a part of a packet

§frame_id: FrameId

Either the last or the current frame id inside current packet, depending on start_frame_flag

§device_address: u16

Transmitting device’s address

§data_len: u8

Length of frame data

§data: [u8; 8]

Frame data

Implementations§

Source§

impl Frame

Source

pub fn from_bxcan_frame(frame: BxFrame) -> Result<Self, FrameError>

Converts a bxcan frame to a ross frame

This is the extended id structure for a ross frame: bit 0: NOT_ERROR_FLAG (if this bit is low, the frame is considered to be an error frame) bit 1: START_FRAME_FLAG (if this bit is high, the frame is considered to be the first frame of a packet) bit 2: MULTI_FRAME_FLAG (if this bit is high, the frame is considered to be only a part of a packet) bits 3 - 7: RESERVED (reserved for future use) bits 8 - 11: LAST_FRAME_ID (most significant nibble (0xf00) of the last frame id) FRAME_ID (most significant nibble (0xf00) of the current frame id) bits 12 - 27 DEVICE_ADDRESS (transmitting device’s address)

Source

pub fn to_bxcan_frame(&self) -> BxFrame

Converts a ross frame to a bxcan frame

Source

pub fn from_usart_frame(encoded: Vec<u8>) -> Result<Self, FrameError>

Converts a USART frame to a ross frame

This is the structure for a USART frame: byte 0: bit 0: NOT_ERROR_FLAG (if this bit is low, the frame is considered to be an error frame) bit 1: START_FRAME_FLAG (if this bit is high, the frame is considered to be the first frame of a packet) bit 2: MULTI_FRAME_FLAG (if this bit is high, the frame is considered to be only a part of a packet)s bit 3: RESERVED (reserved for future use) bits 4 - 7: LAST_FRAME_ID (most significant nibble (0xf00) of the last frame id) FRAME_ID (most significant nibble (0xf00) of the current frame id)

byte 1: LAST_FRAME_ID (least significant byte (0x0ff) of the last frame id) FRAME_ID (least significant byte (0x0ff) of the current frame id)

byte 2: DEVICE_ADDRESS (most significant byte (0xff00) of the device address) byte 3: DEVICE_ADDRESS (least significant byte (0x00ff) of the device address)

byte 4: DATA_LEN (length of frame data) bytes 5 - 12: DATA (frame data)

Source

pub fn to_usart_frame(&self) -> Vec<u8>

Converts a ross frame to a USART frame

Trait Implementations§

Source§

impl Debug for Frame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Frame

Source§

fn eq(&self, other: &Frame) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Frame

Auto Trait Implementations§

§

impl Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnwindSafe for Frame

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.