pub struct Command<T: Instruction> { /* private fields */ }
Expand description
A Comamnd
is an Instruction
with a module address.
It contains everything required to serialize itself into Binary command format.
Implementations§
Source§impl<T: Instruction> Command<T>
impl<T: Instruction> Command<T>
pub fn new(module_address: u8, instruction: T) -> Command<T>
Sourcepub fn module_address(&self) -> u8
pub fn module_address(&self) -> u8
Returns the module address
Sourcepub fn serialize(&self) -> [u8; 9]
pub fn serialize(&self) -> [u8; 9]
Serialize into binary command format suited for RS232, RS485 etc
The array will look like the following:
[MODULE_ADR, CMD_N, TYPE_N, MOTOR_N, VALUE3, VALUE2, VALUE1, VALUE0, CHECKSUM]
Sourcepub fn serialize_i2c(&self) -> [u8; 8]
pub fn serialize_i2c(&self) -> [u8; 8]
Serialize into binary command format suited for I2C
The array will look like the following:
[CMD_N, TYPE_N, MOTOR_N, VALUE3, VALUE2, VALUE1, VALUE0, CHECKSUM]
Sourcepub fn serialize_can(&self) -> [u8; 7]
pub fn serialize_can(&self) -> [u8; 7]
Serialize into binary command format suited for CAN (controller area network)
When using CAN the module address and checksum will be excluded.
The array will look like the following:
[CMD_N, TYPE_N, MOTOR_N, VALUE3, VALUE2, VALUE1, VALUE0]
Trait Implementations§
impl<T: Instruction> StructuralPartialEq for Command<T>
Auto Trait Implementations§
impl<T> Freeze for Command<T>where
T: Freeze,
impl<T> RefUnwindSafe for Command<T>where
T: RefUnwindSafe,
impl<T> Send for Command<T>where
T: Send,
impl<T> Sync for Command<T>where
T: Sync,
impl<T> Unpin for Command<T>where
T: Unpin,
impl<T> UnwindSafe for Command<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more