Struct ross_protocol::frame::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: boolIf this bit is low, the frame is considered to be an error frame
start_frame_flag: boolIf this bit is high, the frame is considered to be the first frame of a packet
multi_frame_flag: boolIf this bit is high, the frame is considered to be only a part of a packet
frame_id: FrameIdEither the last or the current frame id inside current packet, depending on start_frame_flag
device_address: u16Transmitting device’s address
data_len: u8Length of frame data
data: [u8; 8]Frame data
Implementations
sourceimpl Frame
impl Frame
sourcepub fn from_bxcan_frame(frame: BxFrame) -> Result<Self, FrameError>
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)
sourcepub fn to_bxcan_frame(&self) -> BxFrame
pub fn to_bxcan_frame(&self) -> BxFrame
Converts a ross frame to a bxcan frame
sourcepub fn from_usart_frame(encoded: Vec<u8>) -> Result<Self, FrameError>
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)
sourcepub fn to_usart_frame(&self) -> Vec<u8>
pub fn to_usart_frame(&self) -> Vec<u8>
Converts a ross frame to a USART frame
Trait Implementations
impl StructuralPartialEq for Frame
Auto Trait Implementations
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnwindSafe for Frame
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more