pub struct DataPhasePacket {
pub data: Vec<u8>,
}Expand description
McuBoot data phase packet structure
Represents a data phase packet that carries additional data for commands that require it.
The data phase packet is sent after the command packet when the command’s
CommandFlag::HasDataPhase
flag is set. This allows for transmission of variable-length data that exceeds the
command packet’s parameter capacity.
§Usage
If using the McuBoot high-level interface, data phase packets are automatically sent
when a command requires additional data. However, if you’re working with command packets
directly, you’ll need to create and send the corresponding data phase packet manually
for commands that have the CommandFlag::HasDataPhase flag set.
Fields§
§data: Vec<u8>Raw data payload to be transmitted
Trait Implementations§
Source§impl Packet for DataPhasePacket
impl Packet for DataPhasePacket
Source§impl PacketConstruct for DataPhasePacket
impl PacketConstruct for DataPhasePacket
Source§fn construct(&self) -> Vec<u8> ⓘ
fn construct(&self) -> Vec<u8> ⓘ
Constructs a complete data phase packet ready for transmission
This method wraps the data payload with the appropriate McuBoot protocol header to create a properly formatted data phase packet. The header includes the packet type, length, and CRC checksum as required by the protocol.
§Returns
A Vec<u8> containing the complete data phase packet with protocol header:
- Start byte (0x5A)
- Packet code (0xA5)
- Length (2 bytes, little-endian)
- CRC16 (2 bytes, little-endian)
- Data payload (variable length)
Source§impl PacketParse for DataPhasePacket
impl PacketParse for DataPhasePacket
Source§fn parse(bytes: &[u8]) -> Result<DataPhasePacket, CommunicationError>
fn parse(bytes: &[u8]) -> Result<DataPhasePacket, CommunicationError>
Creates a DataPhasePacket from raw bytes
§Arguments
bytes- Raw data bytes to be stored in the packet
§Returns
A Result containing the new DataPhasePacket with the provided data
§Note
This method always succeeds as data phase packets can contain any arbitrary byte sequence as their payload.