MOSIFrame

Struct MOSIFrame 

Source
pub struct MOSIFrame { /* private fields */ }
Expand description

A representation of a SHDLC Master Out Slave In frame. Each frame contains a Frame start byte. The slave address of the device. The command byte. The length of the data being transmitted. The actual data, a checksum followed by the Frame end byte.

Implementations§

Source§

impl MOSIFrame

Source

pub fn new( address: u8, command: u8, data: &[u8], ) -> Result<Self, TranslationError>

Constructs a MOSI frame from the adress, command, and data. This will automatically translate the data using SHDLC byte stuffing.

Source

pub fn get_address(&self) -> u8

Returns the slave adress of the command

Source

pub fn get_command_number(&self) -> u8

Returns the command number/byte of

Source

pub fn get_data_length(&self) -> u8

Returns the length of the data pre byte stuffing

Source

pub fn check_sum(&self) -> u8

Returns the checksum of the MOSIframe

Source

pub fn into_raw(self) -> ArrayVec<u8, 518>

Returns the underlying ArrayVec ready to be written to the device

Source

pub fn validate_checksum(&self) -> bool

Validates the checksum and returns true if its valid

Auto Trait Implementations§

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.