pub struct Cdc2CommandPacket<const CMD: u8, const ECMD: u8, P: Encode> { /* private fields */ }
Expand description
CDC2 (Extended) Command Packet
This type encodes a host-to-device command packet used in the extended CDC2 protocol. The payload type P
must implement Encode
.
All CDC2 commands have a corresponding Cdc2ReplyPacket
from the device, even if the reply contains no
payload. For example, a SystemFlagsPacket
command corresponds to a SystemFlagsReplyPacket
reply.
See Cdc2ReplyPacket
for more info on packet acknowledgement.
§Encoding
This is an extension of the standard CdcCommandPacket
encoding that adds:
- An extended command opcode (
ecmd
). - A CRC16 checksum covering the entire packet (including header).
Field | Size | Description |
---|---|---|
header | 4 | Must be COMMAND_HEADER . |
cmd | 1 | A CDC command opcode, typically USER_CDC (for a brain) or CON_CDC (for a controller). |
ecmd | 1 | A CDC2 extended command opcode. |
size | 1–2 | Number of remaining bytes in the packet (starting at payload through crc16 ), encoded as a VarU16 . |
payload | n | Encoded payload. |
crc16 | 2 | CRC16 checksum of the whole packet, computed with the VEX_CRC16 algorithm. |
Implementations§
Trait Implementations§
Source§impl<const CMD: u8, const ECMD: u8, P: Clone + Encode> Clone for Cdc2CommandPacket<CMD, ECMD, P>
impl<const CMD: u8, const ECMD: u8, P: Clone + Encode> Clone for Cdc2CommandPacket<CMD, ECMD, P>
Source§fn clone(&self) -> Cdc2CommandPacket<CMD, ECMD, P>
fn clone(&self) -> Cdc2CommandPacket<CMD, ECMD, P>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<const CMD: u8, const ECMD: u8, P: Debug + Encode> Debug for Cdc2CommandPacket<CMD, ECMD, P>
impl<const CMD: u8, const ECMD: u8, P: Debug + Encode> Debug for Cdc2CommandPacket<CMD, ECMD, P>
Source§impl<const CMD: u8, const ECMD: u8, P: PartialEq + Encode> PartialEq for Cdc2CommandPacket<CMD, ECMD, P>
impl<const CMD: u8, const ECMD: u8, P: PartialEq + Encode> PartialEq for Cdc2CommandPacket<CMD, ECMD, P>
Source§fn eq(&self, other: &Cdc2CommandPacket<CMD, ECMD, P>) -> bool
fn eq(&self, other: &Cdc2CommandPacket<CMD, ECMD, P>) -> bool
Tests for
self
and other
values to be equal, and is used by ==
.impl<const CMD: u8, const ECMD: u8, P: Copy + Encode> Copy for Cdc2CommandPacket<CMD, ECMD, P>
impl<const CMD: u8, const ECMD: u8, P: Eq + Encode> Eq for Cdc2CommandPacket<CMD, ECMD, P>
impl<const CMD: u8, const ECMD: u8, P: Encode> StructuralPartialEq for Cdc2CommandPacket<CMD, ECMD, P>
Auto Trait Implementations§
impl<const CMD: u8, const ECMD: u8, P> Freeze for Cdc2CommandPacket<CMD, ECMD, P>where
P: Freeze,
impl<const CMD: u8, const ECMD: u8, P> RefUnwindSafe for Cdc2CommandPacket<CMD, ECMD, P>where
P: RefUnwindSafe,
impl<const CMD: u8, const ECMD: u8, P> Send for Cdc2CommandPacket<CMD, ECMD, P>where
P: Send,
impl<const CMD: u8, const ECMD: u8, P> Sync for Cdc2CommandPacket<CMD, ECMD, P>where
P: Sync,
impl<const CMD: u8, const ECMD: u8, P> Unpin for Cdc2CommandPacket<CMD, ECMD, P>where
P: Unpin,
impl<const CMD: u8, const ECMD: u8, P> UnwindSafe for Cdc2CommandPacket<CMD, ECMD, P>where
P: 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