2023-02-22 11:02:43 +08:00
|
|
|
use core_io::{Error as IoError, Read, Write};
|
|
|
|
use io::proto::{ProtoRead, ProtoWrite};
|
2021-10-06 13:02:28 +08:00
|
|
|
|
2023-08-31 17:36:01 +08:00
|
|
|
// maximum size of arbitrary payloads
|
|
|
|
// used by satellite -> master analyzer, subkernel exceptions
|
|
|
|
pub const SAT_PAYLOAD_MAX_SIZE: usize = /*max size*/512 - /*CRC*/4 - /*packet ID*/1 - /*last*/1 - /*length*/2;
|
|
|
|
// used by DDMA, subkernel program data (need to provide extra ID and destination)
|
|
|
|
pub const MASTER_PAYLOAD_MAX_SIZE: usize = SAT_PAYLOAD_MAX_SIZE - /*destination*/1 - /*ID*/4;
|
2023-03-22 12:09:05 +08:00
|
|
|
|
2021-10-06 13:02:28 +08:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
|
|
|
UnknownPacket(u8),
|
2023-02-22 11:02:43 +08:00
|
|
|
Io(IoError),
|
2021-10-06 13:02:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<IoError> for Error {
|
|
|
|
fn from(value: IoError) -> Error {
|
|
|
|
Error::Io(value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-02 14:48:52 +08:00
|
|
|
#[derive(PartialEq, Clone, Copy, Debug)]
|
|
|
|
#[repr(u8)]
|
|
|
|
pub enum PayloadStatus {
|
|
|
|
Middle = 0,
|
|
|
|
First = 1,
|
|
|
|
Last = 2,
|
|
|
|
FirstAndLast = 3,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<u8> for PayloadStatus {
|
|
|
|
fn from(value: u8) -> PayloadStatus {
|
|
|
|
match value {
|
|
|
|
0 => PayloadStatus::Middle,
|
|
|
|
1 => PayloadStatus::First,
|
|
|
|
2 => PayloadStatus::Last,
|
|
|
|
3 => PayloadStatus::FirstAndLast,
|
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PayloadStatus {
|
|
|
|
pub fn is_first(self) -> bool {
|
|
|
|
self == PayloadStatus::First || self == PayloadStatus::FirstAndLast
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_last(self) -> bool {
|
|
|
|
self == PayloadStatus::Last || self == PayloadStatus::FirstAndLast
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_status(first: bool, last: bool) -> PayloadStatus {
|
|
|
|
match (first, last) {
|
|
|
|
(true, true) => PayloadStatus::FirstAndLast,
|
|
|
|
(true, false) => PayloadStatus::First,
|
|
|
|
(false, true) => PayloadStatus::Last,
|
|
|
|
(false, false) => PayloadStatus::Middle,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-06 13:02:28 +08:00
|
|
|
#[derive(PartialEq, Debug)]
|
|
|
|
pub enum Packet {
|
|
|
|
EchoRequest,
|
|
|
|
EchoReply,
|
|
|
|
ResetRequest,
|
|
|
|
ResetAck,
|
|
|
|
TSCAck,
|
|
|
|
|
2023-02-22 11:02:43 +08:00
|
|
|
DestinationStatusRequest {
|
|
|
|
destination: u8,
|
|
|
|
},
|
2021-10-06 13:02:28 +08:00
|
|
|
DestinationDownReply,
|
|
|
|
DestinationOkReply,
|
2023-02-22 11:02:43 +08:00
|
|
|
DestinationSequenceErrorReply {
|
|
|
|
channel: u16,
|
|
|
|
},
|
|
|
|
DestinationCollisionReply {
|
|
|
|
channel: u16,
|
|
|
|
},
|
|
|
|
DestinationBusyReply {
|
|
|
|
channel: u16,
|
|
|
|
},
|
2021-10-06 13:02:28 +08:00
|
|
|
|
2023-02-22 11:02:43 +08:00
|
|
|
RoutingSetPath {
|
|
|
|
destination: u8,
|
|
|
|
hops: [u8; 32],
|
|
|
|
},
|
|
|
|
RoutingSetRank {
|
|
|
|
rank: u8,
|
|
|
|
},
|
2021-10-06 13:02:28 +08:00
|
|
|
RoutingAck,
|
|
|
|
|
2023-02-22 11:02:43 +08:00
|
|
|
MonitorRequest {
|
|
|
|
destination: u8,
|
|
|
|
channel: u16,
|
|
|
|
probe: u8,
|
|
|
|
},
|
|
|
|
MonitorReply {
|
|
|
|
value: u64,
|
|
|
|
},
|
|
|
|
InjectionRequest {
|
|
|
|
destination: u8,
|
|
|
|
channel: u16,
|
|
|
|
overrd: u8,
|
|
|
|
value: u8,
|
|
|
|
},
|
|
|
|
InjectionStatusRequest {
|
|
|
|
destination: u8,
|
|
|
|
channel: u16,
|
|
|
|
overrd: u8,
|
|
|
|
},
|
|
|
|
InjectionStatusReply {
|
|
|
|
value: u8,
|
|
|
|
},
|
2021-10-06 13:02:28 +08:00
|
|
|
|
2023-02-22 11:02:43 +08:00
|
|
|
I2cStartRequest {
|
|
|
|
destination: u8,
|
|
|
|
busno: u8,
|
|
|
|
},
|
|
|
|
I2cRestartRequest {
|
|
|
|
destination: u8,
|
|
|
|
busno: u8,
|
|
|
|
},
|
|
|
|
I2cStopRequest {
|
|
|
|
destination: u8,
|
|
|
|
busno: u8,
|
|
|
|
},
|
|
|
|
I2cWriteRequest {
|
|
|
|
destination: u8,
|
|
|
|
busno: u8,
|
|
|
|
data: u8,
|
|
|
|
},
|
|
|
|
I2cWriteReply {
|
|
|
|
succeeded: bool,
|
|
|
|
ack: bool,
|
|
|
|
},
|
|
|
|
I2cReadRequest {
|
|
|
|
destination: u8,
|
|
|
|
busno: u8,
|
|
|
|
ack: bool,
|
|
|
|
},
|
|
|
|
I2cReadReply {
|
|
|
|
succeeded: bool,
|
|
|
|
data: u8,
|
|
|
|
},
|
|
|
|
I2cBasicReply {
|
|
|
|
succeeded: bool,
|
|
|
|
},
|
|
|
|
I2cSwitchSelectRequest {
|
|
|
|
destination: u8,
|
|
|
|
busno: u8,
|
|
|
|
address: u8,
|
|
|
|
mask: u8,
|
|
|
|
},
|
2021-10-06 13:02:28 +08:00
|
|
|
|
2023-02-22 11:02:43 +08:00
|
|
|
SpiSetConfigRequest {
|
|
|
|
destination: u8,
|
|
|
|
busno: u8,
|
|
|
|
flags: u8,
|
|
|
|
length: u8,
|
|
|
|
div: u8,
|
|
|
|
cs: u8,
|
|
|
|
},
|
|
|
|
SpiWriteRequest {
|
|
|
|
destination: u8,
|
|
|
|
busno: u8,
|
|
|
|
data: u32,
|
|
|
|
},
|
|
|
|
SpiReadRequest {
|
|
|
|
destination: u8,
|
|
|
|
busno: u8,
|
|
|
|
},
|
|
|
|
SpiReadReply {
|
|
|
|
succeeded: bool,
|
|
|
|
data: u32,
|
|
|
|
},
|
|
|
|
SpiBasicReply {
|
|
|
|
succeeded: bool,
|
|
|
|
},
|
2023-03-22 12:09:05 +08:00
|
|
|
|
2023-05-24 10:00:48 +08:00
|
|
|
AnalyzerHeaderRequest {
|
|
|
|
destination: u8,
|
2023-05-19 12:53:33 +08:00
|
|
|
},
|
2023-05-24 10:00:48 +08:00
|
|
|
AnalyzerHeader {
|
|
|
|
sent_bytes: u32,
|
|
|
|
total_byte_count: u64,
|
2023-05-19 12:53:33 +08:00
|
|
|
overflow_occurred: bool,
|
|
|
|
},
|
2023-05-24 10:00:48 +08:00
|
|
|
AnalyzerDataRequest {
|
2023-05-19 12:53:33 +08:00
|
|
|
destination: u8,
|
|
|
|
},
|
2023-05-24 10:00:48 +08:00
|
|
|
AnalyzerData {
|
|
|
|
last: bool,
|
|
|
|
length: u16,
|
2023-08-31 17:36:01 +08:00
|
|
|
data: [u8; SAT_PAYLOAD_MAX_SIZE],
|
2023-05-19 12:53:33 +08:00
|
|
|
},
|
|
|
|
|
2023-03-27 15:53:32 +08:00
|
|
|
DmaAddTraceRequest {
|
|
|
|
destination: u8,
|
|
|
|
id: u32,
|
2023-11-02 14:48:52 +08:00
|
|
|
status: PayloadStatus,
|
2023-03-27 15:53:32 +08:00
|
|
|
length: u16,
|
2023-08-31 17:36:01 +08:00
|
|
|
trace: [u8; MASTER_PAYLOAD_MAX_SIZE],
|
2023-03-27 15:53:32 +08:00
|
|
|
},
|
|
|
|
DmaAddTraceReply {
|
|
|
|
succeeded: bool,
|
|
|
|
},
|
|
|
|
DmaRemoveTraceRequest {
|
|
|
|
destination: u8,
|
|
|
|
id: u32,
|
|
|
|
},
|
|
|
|
DmaRemoveTraceReply {
|
|
|
|
succeeded: bool,
|
|
|
|
},
|
|
|
|
DmaPlaybackRequest {
|
|
|
|
destination: u8,
|
|
|
|
id: u32,
|
|
|
|
timestamp: u64,
|
|
|
|
},
|
|
|
|
DmaPlaybackReply {
|
|
|
|
succeeded: bool,
|
|
|
|
},
|
|
|
|
DmaPlaybackStatus {
|
|
|
|
destination: u8,
|
|
|
|
id: u32,
|
|
|
|
error: u8,
|
|
|
|
channel: u32,
|
|
|
|
timestamp: u64,
|
2023-03-22 12:09:05 +08:00
|
|
|
},
|
2023-08-31 17:36:01 +08:00
|
|
|
|
|
|
|
SubkernelAddDataRequest {
|
|
|
|
destination: u8,
|
|
|
|
id: u32,
|
2023-11-02 14:48:52 +08:00
|
|
|
status: PayloadStatus,
|
2023-08-31 17:36:01 +08:00
|
|
|
length: u16,
|
|
|
|
data: [u8; MASTER_PAYLOAD_MAX_SIZE],
|
|
|
|
},
|
|
|
|
SubkernelAddDataReply {
|
|
|
|
succeeded: bool,
|
|
|
|
},
|
|
|
|
SubkernelLoadRunRequest {
|
|
|
|
destination: u8,
|
|
|
|
id: u32,
|
|
|
|
run: bool,
|
|
|
|
},
|
|
|
|
SubkernelLoadRunReply {
|
|
|
|
succeeded: bool,
|
|
|
|
},
|
|
|
|
SubkernelStopRequest {
|
|
|
|
destination: u8,
|
|
|
|
},
|
|
|
|
SubkernelStopReply {
|
|
|
|
succeeded: bool,
|
|
|
|
},
|
|
|
|
SubkernelFinished {
|
|
|
|
id: u32,
|
|
|
|
with_exception: bool,
|
|
|
|
},
|
|
|
|
SubkernelExceptionRequest {
|
|
|
|
destination: u8,
|
|
|
|
},
|
|
|
|
SubkernelException {
|
|
|
|
last: bool,
|
|
|
|
length: u16,
|
|
|
|
data: [u8; SAT_PAYLOAD_MAX_SIZE],
|
|
|
|
},
|
|
|
|
SubkernelMessage {
|
|
|
|
destination: u8,
|
|
|
|
id: u32,
|
2023-11-02 14:48:52 +08:00
|
|
|
status: PayloadStatus,
|
2023-08-31 17:36:01 +08:00
|
|
|
length: u16,
|
|
|
|
data: [u8; MASTER_PAYLOAD_MAX_SIZE],
|
|
|
|
},
|
|
|
|
SubkernelMessageAck {
|
|
|
|
destination: u8,
|
|
|
|
},
|
2021-10-06 13:02:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Packet {
|
|
|
|
pub fn read_from<R>(reader: &mut R) -> Result<Self, Error>
|
2023-02-22 11:02:43 +08:00
|
|
|
where R: Read + ?Sized {
|
2021-10-06 13:02:28 +08:00
|
|
|
Ok(match reader.read_u8()? {
|
|
|
|
0x00 => Packet::EchoRequest,
|
|
|
|
0x01 => Packet::EchoReply,
|
|
|
|
0x02 => Packet::ResetRequest,
|
|
|
|
0x03 => Packet::ResetAck,
|
|
|
|
0x04 => Packet::TSCAck,
|
|
|
|
|
|
|
|
0x20 => Packet::DestinationStatusRequest {
|
2023-02-22 11:02:43 +08:00
|
|
|
destination: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x21 => Packet::DestinationDownReply,
|
|
|
|
0x22 => Packet::DestinationOkReply,
|
|
|
|
0x23 => Packet::DestinationSequenceErrorReply {
|
2023-02-22 11:02:43 +08:00
|
|
|
channel: reader.read_u16()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x24 => Packet::DestinationCollisionReply {
|
2023-02-22 11:02:43 +08:00
|
|
|
channel: reader.read_u16()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x25 => Packet::DestinationBusyReply {
|
2023-02-22 11:02:43 +08:00
|
|
|
channel: reader.read_u16()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
0x30 => {
|
|
|
|
let destination = reader.read_u8()?;
|
|
|
|
let mut hops = [0; 32];
|
|
|
|
reader.read_exact(&mut hops)?;
|
|
|
|
Packet::RoutingSetPath {
|
|
|
|
destination: destination,
|
2023-02-22 11:02:43 +08:00
|
|
|
hops: hops,
|
2021-10-06 13:02:28 +08:00
|
|
|
}
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
0x31 => Packet::RoutingSetRank {
|
2023-02-22 11:02:43 +08:00
|
|
|
rank: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x32 => Packet::RoutingAck,
|
|
|
|
|
|
|
|
0x40 => Packet::MonitorRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
channel: reader.read_u16()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
probe: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x41 => Packet::MonitorReply {
|
2023-02-22 11:02:43 +08:00
|
|
|
value: reader.read_u64()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x50 => Packet::InjectionRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
channel: reader.read_u16()?,
|
|
|
|
overrd: reader.read_u8()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
value: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x51 => Packet::InjectionStatusRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
channel: reader.read_u16()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
overrd: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x52 => Packet::InjectionStatusReply {
|
2023-02-22 11:02:43 +08:00
|
|
|
value: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
0x80 => Packet::I2cStartRequest {
|
|
|
|
destination: reader.read_u8()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
busno: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x81 => Packet::I2cRestartRequest {
|
|
|
|
destination: reader.read_u8()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
busno: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x82 => Packet::I2cStopRequest {
|
|
|
|
destination: reader.read_u8()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
busno: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x83 => Packet::I2cWriteRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
busno: reader.read_u8()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
data: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x84 => Packet::I2cWriteReply {
|
|
|
|
succeeded: reader.read_bool()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
ack: reader.read_bool()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x85 => Packet::I2cReadRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
busno: reader.read_u8()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
ack: reader.read_bool()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x86 => Packet::I2cReadReply {
|
|
|
|
succeeded: reader.read_bool()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
data: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x87 => Packet::I2cBasicReply {
|
2023-02-22 11:02:43 +08:00
|
|
|
succeeded: reader.read_bool()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
2022-03-02 10:52:27 +08:00
|
|
|
0x88 => Packet::I2cSwitchSelectRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
busno: reader.read_u8()?,
|
|
|
|
address: reader.read_u8()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
mask: reader.read_u8()?,
|
2022-03-02 10:52:27 +08:00
|
|
|
},
|
2021-10-06 13:02:28 +08:00
|
|
|
|
|
|
|
0x90 => Packet::SpiSetConfigRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
busno: reader.read_u8()?,
|
|
|
|
flags: reader.read_u8()?,
|
|
|
|
length: reader.read_u8()?,
|
|
|
|
div: reader.read_u8()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
cs: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
/* 0x91: was Packet::SpiSetXferRequest */
|
|
|
|
0x92 => Packet::SpiWriteRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
busno: reader.read_u8()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
data: reader.read_u32()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x93 => Packet::SpiReadRequest {
|
|
|
|
destination: reader.read_u8()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
busno: reader.read_u8()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x94 => Packet::SpiReadReply {
|
|
|
|
succeeded: reader.read_bool()?,
|
2023-02-22 11:02:43 +08:00
|
|
|
data: reader.read_u32()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
0x95 => Packet::SpiBasicReply {
|
2023-02-22 11:02:43 +08:00
|
|
|
succeeded: reader.read_bool()?,
|
2021-10-06 13:02:28 +08:00
|
|
|
},
|
|
|
|
|
2023-05-19 12:53:33 +08:00
|
|
|
0xa0 => Packet::AnalyzerHeaderRequest {
|
2023-05-24 10:00:48 +08:00
|
|
|
destination: reader.read_u8()?,
|
2023-05-19 12:53:33 +08:00
|
|
|
},
|
|
|
|
0xa1 => Packet::AnalyzerHeader {
|
2023-05-24 10:00:48 +08:00
|
|
|
sent_bytes: reader.read_u32()?,
|
|
|
|
total_byte_count: reader.read_u64()?,
|
2023-05-19 12:53:33 +08:00
|
|
|
overflow_occurred: reader.read_bool()?,
|
|
|
|
},
|
|
|
|
0xa2 => Packet::AnalyzerDataRequest {
|
2023-05-24 10:00:48 +08:00
|
|
|
destination: reader.read_u8()?,
|
2023-05-19 12:53:33 +08:00
|
|
|
},
|
|
|
|
0xa3 => {
|
|
|
|
let last = reader.read_bool()?;
|
|
|
|
let length = reader.read_u16()?;
|
2023-08-31 17:36:01 +08:00
|
|
|
let mut data: [u8; SAT_PAYLOAD_MAX_SIZE] = [0; SAT_PAYLOAD_MAX_SIZE];
|
2023-05-19 12:53:33 +08:00
|
|
|
reader.read_exact(&mut data[0..length as usize])?;
|
|
|
|
Packet::AnalyzerData {
|
|
|
|
last: last,
|
|
|
|
length: length,
|
2023-05-24 10:00:48 +08:00
|
|
|
data: data,
|
2023-05-19 12:53:33 +08:00
|
|
|
}
|
2023-05-24 10:00:48 +08:00
|
|
|
}
|
2023-05-19 12:53:33 +08:00
|
|
|
|
2023-03-27 15:53:32 +08:00
|
|
|
0xb0 => {
|
2023-03-22 12:09:05 +08:00
|
|
|
let destination = reader.read_u8()?;
|
|
|
|
let id = reader.read_u32()?;
|
2023-11-02 14:48:52 +08:00
|
|
|
let status = PayloadStatus::from(reader.read_u8()?);
|
2023-03-22 12:09:05 +08:00
|
|
|
let length = reader.read_u16()?;
|
2023-08-31 17:36:01 +08:00
|
|
|
let mut trace: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE];
|
2023-03-22 12:09:05 +08:00
|
|
|
reader.read_exact(&mut trace[0..length as usize])?;
|
|
|
|
Packet::DmaAddTraceRequest {
|
|
|
|
destination: destination,
|
|
|
|
id: id,
|
2023-11-02 14:48:52 +08:00
|
|
|
status: status,
|
2023-03-22 12:09:05 +08:00
|
|
|
length: length as u16,
|
|
|
|
trace: trace,
|
|
|
|
}
|
2023-03-27 15:53:32 +08:00
|
|
|
}
|
2023-03-22 12:09:05 +08:00
|
|
|
0xb1 => Packet::DmaAddTraceReply {
|
2023-03-27 15:53:32 +08:00
|
|
|
succeeded: reader.read_bool()?,
|
2023-03-22 12:09:05 +08:00
|
|
|
},
|
|
|
|
0xb2 => Packet::DmaRemoveTraceRequest {
|
|
|
|
destination: reader.read_u8()?,
|
2023-03-27 15:53:32 +08:00
|
|
|
id: reader.read_u32()?,
|
2023-03-22 12:09:05 +08:00
|
|
|
},
|
|
|
|
0xb3 => Packet::DmaRemoveTraceReply {
|
2023-03-27 15:53:32 +08:00
|
|
|
succeeded: reader.read_bool()?,
|
2023-03-22 12:09:05 +08:00
|
|
|
},
|
|
|
|
0xb4 => Packet::DmaPlaybackRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
id: reader.read_u32()?,
|
2023-03-27 15:53:32 +08:00
|
|
|
timestamp: reader.read_u64()?,
|
2023-03-22 12:09:05 +08:00
|
|
|
},
|
|
|
|
0xb5 => Packet::DmaPlaybackReply {
|
2023-03-27 15:53:32 +08:00
|
|
|
succeeded: reader.read_bool()?,
|
2023-03-22 12:09:05 +08:00
|
|
|
},
|
|
|
|
0xb6 => Packet::DmaPlaybackStatus {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
id: reader.read_u32()?,
|
|
|
|
error: reader.read_u8()?,
|
|
|
|
channel: reader.read_u32()?,
|
2023-03-27 15:53:32 +08:00
|
|
|
timestamp: reader.read_u64()?,
|
2023-03-22 12:09:05 +08:00
|
|
|
},
|
|
|
|
|
2023-08-31 17:36:01 +08:00
|
|
|
0xc0 => {
|
|
|
|
let destination = reader.read_u8()?;
|
|
|
|
let id = reader.read_u32()?;
|
2023-11-02 14:48:52 +08:00
|
|
|
let status = PayloadStatus::from(reader.read_u8()?);
|
2023-08-31 17:36:01 +08:00
|
|
|
let length = reader.read_u16()?;
|
|
|
|
let mut data: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE];
|
|
|
|
reader.read_exact(&mut data[0..length as usize])?;
|
|
|
|
Packet::SubkernelAddDataRequest {
|
|
|
|
destination: destination,
|
|
|
|
id: id,
|
2023-11-02 14:48:52 +08:00
|
|
|
status: status,
|
2023-08-31 17:36:01 +08:00
|
|
|
length: length as u16,
|
|
|
|
data: data,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
0xc1 => Packet::SubkernelAddDataReply {
|
|
|
|
succeeded: reader.read_bool()?,
|
|
|
|
},
|
|
|
|
0xc4 => Packet::SubkernelLoadRunRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
id: reader.read_u32()?,
|
|
|
|
run: reader.read_bool()?,
|
|
|
|
},
|
|
|
|
0xc5 => Packet::SubkernelLoadRunReply {
|
|
|
|
succeeded: reader.read_bool()?,
|
|
|
|
},
|
|
|
|
0xc6 => Packet::SubkernelStopRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
},
|
|
|
|
0xc7 => Packet::SubkernelStopReply {
|
|
|
|
succeeded: reader.read_bool()?,
|
|
|
|
},
|
|
|
|
0xc8 => Packet::SubkernelFinished {
|
|
|
|
id: reader.read_u32()?,
|
|
|
|
with_exception: reader.read_bool()?,
|
|
|
|
},
|
|
|
|
0xc9 => Packet::SubkernelExceptionRequest {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
},
|
|
|
|
0xca => {
|
|
|
|
let last = reader.read_bool()?;
|
|
|
|
let length = reader.read_u16()?;
|
|
|
|
let mut data: [u8; SAT_PAYLOAD_MAX_SIZE] = [0; SAT_PAYLOAD_MAX_SIZE];
|
|
|
|
reader.read_exact(&mut data[0..length as usize])?;
|
|
|
|
Packet::SubkernelException {
|
|
|
|
last: last,
|
|
|
|
length: length,
|
|
|
|
data: data,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
0xcb => {
|
|
|
|
let destination = reader.read_u8()?;
|
|
|
|
let id = reader.read_u32()?;
|
2023-11-02 14:48:52 +08:00
|
|
|
let status = PayloadStatus::from(reader.read_u8()?);
|
2023-08-31 17:36:01 +08:00
|
|
|
let length = reader.read_u16()?;
|
|
|
|
let mut data: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE];
|
|
|
|
reader.read_exact(&mut data[0..length as usize])?;
|
|
|
|
Packet::SubkernelMessage {
|
|
|
|
destination: destination,
|
|
|
|
id: id,
|
2023-11-02 14:48:52 +08:00
|
|
|
status: status,
|
2023-08-31 17:36:01 +08:00
|
|
|
length: length as u16,
|
|
|
|
data: data,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
0xcc => Packet::SubkernelMessageAck {
|
|
|
|
destination: reader.read_u8()?,
|
|
|
|
},
|
|
|
|
|
2023-02-22 11:02:43 +08:00
|
|
|
ty => return Err(Error::UnknownPacket(ty)),
|
2021-10-06 13:02:28 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn write_to<W>(&self, writer: &mut W) -> Result<(), IoError>
|
2023-02-22 11:02:43 +08:00
|
|
|
where W: Write + ?Sized {
|
2021-10-06 13:02:28 +08:00
|
|
|
match *self {
|
2023-02-22 11:02:43 +08:00
|
|
|
Packet::EchoRequest => writer.write_u8(0x00)?,
|
|
|
|
Packet::EchoReply => writer.write_u8(0x01)?,
|
|
|
|
Packet::ResetRequest => writer.write_u8(0x02)?,
|
|
|
|
Packet::ResetAck => writer.write_u8(0x03)?,
|
|
|
|
Packet::TSCAck => writer.write_u8(0x04)?,
|
2021-10-06 13:02:28 +08:00
|
|
|
|
|
|
|
Packet::DestinationStatusRequest { destination } => {
|
|
|
|
writer.write_u8(0x20)?;
|
|
|
|
writer.write_u8(destination)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
|
|
|
Packet::DestinationDownReply => writer.write_u8(0x21)?,
|
|
|
|
Packet::DestinationOkReply => writer.write_u8(0x22)?,
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::DestinationSequenceErrorReply { channel } => {
|
|
|
|
writer.write_u8(0x23)?;
|
|
|
|
writer.write_u16(channel)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::DestinationCollisionReply { channel } => {
|
|
|
|
writer.write_u8(0x24)?;
|
|
|
|
writer.write_u16(channel)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::DestinationBusyReply { channel } => {
|
|
|
|
writer.write_u8(0x25)?;
|
|
|
|
writer.write_u16(channel)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
|
|
|
|
Packet::RoutingSetPath { destination, hops } => {
|
|
|
|
writer.write_u8(0x30)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_all(&hops)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::RoutingSetRank { rank } => {
|
|
|
|
writer.write_u8(0x31)?;
|
|
|
|
writer.write_u8(rank)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
|
|
|
Packet::RoutingAck => writer.write_u8(0x32)?,
|
2021-10-06 13:02:28 +08:00
|
|
|
|
2023-02-22 11:02:43 +08:00
|
|
|
Packet::MonitorRequest {
|
|
|
|
destination,
|
|
|
|
channel,
|
|
|
|
probe,
|
|
|
|
} => {
|
2021-10-06 13:02:28 +08:00
|
|
|
writer.write_u8(0x40)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u16(channel)?;
|
|
|
|
writer.write_u8(probe)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::MonitorReply { value } => {
|
|
|
|
writer.write_u8(0x41)?;
|
2022-03-17 20:26:44 +08:00
|
|
|
writer.write_u64(value)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
|
|
|
Packet::InjectionRequest {
|
|
|
|
destination,
|
|
|
|
channel,
|
|
|
|
overrd,
|
|
|
|
value,
|
|
|
|
} => {
|
2021-10-06 13:02:28 +08:00
|
|
|
writer.write_u8(0x50)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u16(channel)?;
|
|
|
|
writer.write_u8(overrd)?;
|
|
|
|
writer.write_u8(value)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
|
|
|
Packet::InjectionStatusRequest {
|
|
|
|
destination,
|
|
|
|
channel,
|
|
|
|
overrd,
|
|
|
|
} => {
|
2021-10-06 13:02:28 +08:00
|
|
|
writer.write_u8(0x51)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u16(channel)?;
|
|
|
|
writer.write_u8(overrd)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::InjectionStatusReply { value } => {
|
|
|
|
writer.write_u8(0x52)?;
|
|
|
|
writer.write_u8(value)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
|
|
|
|
Packet::I2cStartRequest { destination, busno } => {
|
|
|
|
writer.write_u8(0x80)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u8(busno)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::I2cRestartRequest { destination, busno } => {
|
|
|
|
writer.write_u8(0x81)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u8(busno)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::I2cStopRequest { destination, busno } => {
|
|
|
|
writer.write_u8(0x82)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u8(busno)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
|
|
|
Packet::I2cWriteRequest {
|
|
|
|
destination,
|
|
|
|
busno,
|
|
|
|
data,
|
|
|
|
} => {
|
2021-10-06 13:02:28 +08:00
|
|
|
writer.write_u8(0x83)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u8(busno)?;
|
|
|
|
writer.write_u8(data)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::I2cWriteReply { succeeded, ack } => {
|
|
|
|
writer.write_u8(0x84)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
|
|
|
writer.write_bool(ack)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
|
|
|
Packet::I2cReadRequest {
|
|
|
|
destination,
|
|
|
|
busno,
|
|
|
|
ack,
|
|
|
|
} => {
|
2021-10-06 13:02:28 +08:00
|
|
|
writer.write_u8(0x85)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u8(busno)?;
|
|
|
|
writer.write_bool(ack)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::I2cReadReply { succeeded, data } => {
|
|
|
|
writer.write_u8(0x86)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
|
|
|
writer.write_u8(data)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::I2cBasicReply { succeeded } => {
|
|
|
|
writer.write_u8(0x87)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
|
|
|
Packet::I2cSwitchSelectRequest {
|
|
|
|
destination,
|
|
|
|
busno,
|
|
|
|
address,
|
|
|
|
mask,
|
|
|
|
} => {
|
2022-03-02 10:52:27 +08:00
|
|
|
writer.write_u8(0x88)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u8(busno)?;
|
|
|
|
writer.write_u8(address)?;
|
|
|
|
writer.write_u8(mask)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
|
2023-02-22 11:02:43 +08:00
|
|
|
Packet::SpiSetConfigRequest {
|
|
|
|
destination,
|
|
|
|
busno,
|
|
|
|
flags,
|
|
|
|
length,
|
|
|
|
div,
|
|
|
|
cs,
|
|
|
|
} => {
|
2021-10-06 13:02:28 +08:00
|
|
|
writer.write_u8(0x90)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u8(busno)?;
|
|
|
|
writer.write_u8(flags)?;
|
|
|
|
writer.write_u8(length)?;
|
|
|
|
writer.write_u8(div)?;
|
|
|
|
writer.write_u8(cs)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
|
|
|
Packet::SpiWriteRequest {
|
|
|
|
destination,
|
|
|
|
busno,
|
|
|
|
data,
|
|
|
|
} => {
|
2021-10-06 13:02:28 +08:00
|
|
|
writer.write_u8(0x92)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u8(busno)?;
|
|
|
|
writer.write_u32(data)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::SpiReadRequest { destination, busno } => {
|
|
|
|
writer.write_u8(0x93)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u8(busno)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::SpiReadReply { succeeded, data } => {
|
|
|
|
writer.write_u8(0x94)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
|
|
|
writer.write_u32(data)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
Packet::SpiBasicReply { succeeded } => {
|
|
|
|
writer.write_u8(0x95)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
2023-02-22 11:02:43 +08:00
|
|
|
}
|
2023-03-22 12:09:05 +08:00
|
|
|
|
2023-05-19 12:53:33 +08:00
|
|
|
Packet::AnalyzerHeaderRequest { destination } => {
|
|
|
|
writer.write_u8(0xa0)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
}
|
2023-05-24 10:00:48 +08:00
|
|
|
Packet::AnalyzerHeader {
|
|
|
|
sent_bytes,
|
|
|
|
total_byte_count,
|
|
|
|
overflow_occurred,
|
|
|
|
} => {
|
2023-05-19 12:53:33 +08:00
|
|
|
writer.write_u8(0xa1)?;
|
|
|
|
writer.write_u32(sent_bytes)?;
|
|
|
|
writer.write_u64(total_byte_count)?;
|
|
|
|
writer.write_bool(overflow_occurred)?;
|
|
|
|
}
|
|
|
|
Packet::AnalyzerDataRequest { destination } => {
|
|
|
|
writer.write_u8(0xa2)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
}
|
2023-05-24 10:00:48 +08:00
|
|
|
Packet::AnalyzerData { last, length, data } => {
|
2023-05-19 12:53:33 +08:00
|
|
|
writer.write_u8(0xa3)?;
|
|
|
|
writer.write_bool(last)?;
|
|
|
|
writer.write_u16(length)?;
|
|
|
|
writer.write_all(&data[0..length as usize])?;
|
|
|
|
}
|
|
|
|
|
2023-03-27 15:53:32 +08:00
|
|
|
Packet::DmaAddTraceRequest {
|
|
|
|
destination,
|
|
|
|
id,
|
2023-11-02 14:48:52 +08:00
|
|
|
status,
|
2023-03-27 15:53:32 +08:00
|
|
|
trace,
|
|
|
|
length,
|
2023-03-22 12:09:05 +08:00
|
|
|
} => {
|
|
|
|
writer.write_u8(0xb0)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u32(id)?;
|
2023-11-02 14:48:52 +08:00
|
|
|
writer.write_u8(status as u8)?;
|
2023-03-22 12:09:05 +08:00
|
|
|
// trace may be broken down to fit within drtio aux memory limit
|
|
|
|
// will be reconstructed by satellite
|
|
|
|
writer.write_u16(length)?;
|
|
|
|
writer.write_all(&trace[0..length as usize])?;
|
|
|
|
}
|
|
|
|
Packet::DmaAddTraceReply { succeeded } => {
|
|
|
|
writer.write_u8(0xb1)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
|
|
|
}
|
|
|
|
Packet::DmaRemoveTraceRequest { destination, id } => {
|
|
|
|
writer.write_u8(0xb2)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u32(id)?;
|
|
|
|
}
|
|
|
|
Packet::DmaRemoveTraceReply { succeeded } => {
|
|
|
|
writer.write_u8(0xb3)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
|
|
|
}
|
2023-03-27 15:53:32 +08:00
|
|
|
Packet::DmaPlaybackRequest {
|
|
|
|
destination,
|
|
|
|
id,
|
|
|
|
timestamp,
|
2023-03-22 12:09:05 +08:00
|
|
|
} => {
|
|
|
|
writer.write_u8(0xb4)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u32(id)?;
|
|
|
|
writer.write_u64(timestamp)?;
|
|
|
|
}
|
|
|
|
Packet::DmaPlaybackReply { succeeded } => {
|
|
|
|
writer.write_u8(0xb5)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
|
|
|
}
|
2023-03-27 15:53:32 +08:00
|
|
|
Packet::DmaPlaybackStatus {
|
|
|
|
destination,
|
|
|
|
id,
|
|
|
|
error,
|
|
|
|
channel,
|
|
|
|
timestamp,
|
2023-03-22 12:09:05 +08:00
|
|
|
} => {
|
|
|
|
writer.write_u8(0xb6)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u32(id)?;
|
|
|
|
writer.write_u8(error)?;
|
|
|
|
writer.write_u32(channel)?;
|
|
|
|
writer.write_u64(timestamp)?;
|
|
|
|
}
|
2023-08-31 17:36:01 +08:00
|
|
|
|
|
|
|
Packet::SubkernelAddDataRequest {
|
|
|
|
destination,
|
|
|
|
id,
|
2023-11-02 14:48:52 +08:00
|
|
|
status,
|
2023-08-31 17:36:01 +08:00
|
|
|
data,
|
|
|
|
length,
|
|
|
|
} => {
|
|
|
|
writer.write_u8(0xc0)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u32(id)?;
|
2023-11-02 14:48:52 +08:00
|
|
|
writer.write_u8(status as u8)?;
|
2023-08-31 17:36:01 +08:00
|
|
|
writer.write_u16(length)?;
|
|
|
|
writer.write_all(&data[0..length as usize])?;
|
|
|
|
}
|
|
|
|
Packet::SubkernelAddDataReply { succeeded } => {
|
|
|
|
writer.write_u8(0xc1)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
|
|
|
}
|
|
|
|
Packet::SubkernelLoadRunRequest { destination, id, run } => {
|
|
|
|
writer.write_u8(0xc4)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u32(id)?;
|
|
|
|
writer.write_bool(run)?;
|
|
|
|
}
|
|
|
|
Packet::SubkernelLoadRunReply { succeeded } => {
|
|
|
|
writer.write_u8(0xc5)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
|
|
|
}
|
|
|
|
Packet::SubkernelStopRequest { destination } => {
|
|
|
|
writer.write_u8(0xc6)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
}
|
|
|
|
Packet::SubkernelStopReply { succeeded } => {
|
|
|
|
writer.write_u8(0xc7)?;
|
|
|
|
writer.write_bool(succeeded)?;
|
|
|
|
}
|
|
|
|
Packet::SubkernelFinished { id, with_exception } => {
|
|
|
|
writer.write_u8(0xc8)?;
|
|
|
|
writer.write_u32(id)?;
|
|
|
|
writer.write_bool(with_exception)?;
|
|
|
|
}
|
|
|
|
Packet::SubkernelExceptionRequest { destination } => {
|
|
|
|
writer.write_u8(0xc9)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
}
|
|
|
|
Packet::SubkernelException { last, length, data } => {
|
|
|
|
writer.write_u8(0xca)?;
|
|
|
|
writer.write_bool(last)?;
|
|
|
|
writer.write_u16(length)?;
|
|
|
|
writer.write_all(&data[0..length as usize])?;
|
|
|
|
}
|
|
|
|
Packet::SubkernelMessage {
|
|
|
|
destination,
|
|
|
|
id,
|
2023-11-02 14:48:52 +08:00
|
|
|
status,
|
2023-08-31 17:36:01 +08:00
|
|
|
data,
|
|
|
|
length,
|
|
|
|
} => {
|
|
|
|
writer.write_u8(0xcb)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
writer.write_u32(id)?;
|
2023-11-02 14:48:52 +08:00
|
|
|
writer.write_u8(status as u8)?;
|
2023-08-31 17:36:01 +08:00
|
|
|
writer.write_u16(length)?;
|
|
|
|
writer.write_all(&data[0..length as usize])?;
|
|
|
|
}
|
|
|
|
Packet::SubkernelMessageAck { destination } => {
|
|
|
|
writer.write_u8(0xcc)?;
|
|
|
|
writer.write_u8(destination)?;
|
|
|
|
}
|
2021-10-06 13:02:28 +08:00
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|