drtio-proto: (N)ACK -> Reply { succeeded }
This commit is contained in:
parent
5f5b714838
commit
5b4202cde7
|
@ -331,6 +331,16 @@ pub enum Packet {
|
||||||
CoreMgmtAllocatorDebugRequest {
|
CoreMgmtAllocatorDebugRequest {
|
||||||
destination: u8,
|
destination: u8,
|
||||||
},
|
},
|
||||||
|
CoreMgmtFlashRequest {
|
||||||
|
destination: u8,
|
||||||
|
last: bool,
|
||||||
|
length: u16,
|
||||||
|
data: [u8; MASTER_PAYLOAD_MAX_SIZE],
|
||||||
|
},
|
||||||
|
CoreMgmtDropLinkAck {
|
||||||
|
destination: u8,
|
||||||
|
},
|
||||||
|
CoreMgmtDropLink,
|
||||||
CoreMgmtGetLogReply {
|
CoreMgmtGetLogReply {
|
||||||
last: bool,
|
last: bool,
|
||||||
length: u16,
|
length: u16,
|
||||||
|
@ -341,8 +351,9 @@ pub enum Packet {
|
||||||
length: u16,
|
length: u16,
|
||||||
value: [u8; SAT_PAYLOAD_MAX_SIZE],
|
value: [u8; SAT_PAYLOAD_MAX_SIZE],
|
||||||
},
|
},
|
||||||
CoreMgmtAck,
|
CoreMgmtReply {
|
||||||
CoreMgmtNack,
|
succeeded: bool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Packet {
|
impl Packet {
|
||||||
|
@ -682,6 +693,23 @@ impl Packet {
|
||||||
destination: reader.read_u8()?,
|
destination: reader.read_u8()?,
|
||||||
},
|
},
|
||||||
0xdb => {
|
0xdb => {
|
||||||
|
let destination = reader.read_u8()?;
|
||||||
|
let last = reader.read_bool()?;
|
||||||
|
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::CoreMgmtFlashRequest {
|
||||||
|
destination: destination,
|
||||||
|
last: last,
|
||||||
|
length: length,
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0xdc => Packet::CoreMgmtDropLinkAck {
|
||||||
|
destination: reader.read_u8()?,
|
||||||
|
},
|
||||||
|
0xdd => Packet::CoreMgmtDropLink,
|
||||||
|
0xde => {
|
||||||
let last = reader.read_bool()?;
|
let last = reader.read_bool()?;
|
||||||
let length = reader.read_u16()?;
|
let length = reader.read_u16()?;
|
||||||
let mut data: [u8; SAT_PAYLOAD_MAX_SIZE] = [0; SAT_PAYLOAD_MAX_SIZE];
|
let mut data: [u8; SAT_PAYLOAD_MAX_SIZE] = [0; SAT_PAYLOAD_MAX_SIZE];
|
||||||
|
@ -692,7 +720,7 @@ impl Packet {
|
||||||
data: data,
|
data: data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0xdc => {
|
0xdf => {
|
||||||
let last = reader.read_bool()?;
|
let last = reader.read_bool()?;
|
||||||
let length = reader.read_u16()?;
|
let length = reader.read_u16()?;
|
||||||
let mut value: [u8; SAT_PAYLOAD_MAX_SIZE] = [0; SAT_PAYLOAD_MAX_SIZE];
|
let mut value: [u8; SAT_PAYLOAD_MAX_SIZE] = [0; SAT_PAYLOAD_MAX_SIZE];
|
||||||
|
@ -703,8 +731,9 @@ impl Packet {
|
||||||
value: value,
|
value: value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0xdd => Packet::CoreMgmtAck,
|
0xe0 => Packet::CoreMgmtReply {
|
||||||
0xde => Packet::CoreMgmtNack,
|
succeeded: reader.read_bool()?,
|
||||||
|
},
|
||||||
|
|
||||||
ty => return Err(Error::UnknownPacket(ty)),
|
ty => return Err(Error::UnknownPacket(ty)),
|
||||||
})
|
})
|
||||||
|
@ -1149,20 +1178,39 @@ impl Packet {
|
||||||
writer.write_u8(0xda)?;
|
writer.write_u8(0xda)?;
|
||||||
writer.write_u8(destination)?;
|
writer.write_u8(destination)?;
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtGetLogReply { last, length, data } => {
|
Packet::CoreMgmtFlashRequest {
|
||||||
|
destination,
|
||||||
|
last,
|
||||||
|
length,
|
||||||
|
data,
|
||||||
|
} => {
|
||||||
writer.write_u8(0xdb)?;
|
writer.write_u8(0xdb)?;
|
||||||
|
writer.write_u8(destination)?;
|
||||||
|
writer.write_bool(last)?;
|
||||||
|
writer.write_u16(length)?;
|
||||||
|
writer.write_all(&data[..length as usize])?;
|
||||||
|
}
|
||||||
|
Packet::CoreMgmtDropLinkAck { destination } => {
|
||||||
|
writer.write_u8(0xdc)?;
|
||||||
|
writer.write_u8(destination)?;
|
||||||
|
}
|
||||||
|
Packet::CoreMgmtDropLink => writer.write_u8(0xdd)?,
|
||||||
|
Packet::CoreMgmtGetLogReply { last, length, data } => {
|
||||||
|
writer.write_u8(0xde)?;
|
||||||
writer.write_bool(last)?;
|
writer.write_bool(last)?;
|
||||||
writer.write_u16(length)?;
|
writer.write_u16(length)?;
|
||||||
writer.write_all(&data[0..length as usize])?;
|
writer.write_all(&data[0..length as usize])?;
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtConfigReadReply { last, length, value } => {
|
Packet::CoreMgmtConfigReadReply { last, length, value } => {
|
||||||
writer.write_u8(0xdc)?;
|
writer.write_u8(0xdf)?;
|
||||||
writer.write_bool(last)?;
|
writer.write_bool(last)?;
|
||||||
writer.write_u16(length)?;
|
writer.write_u16(length)?;
|
||||||
writer.write_all(&value[0..length as usize])?;
|
writer.write_all(&value[0..length as usize])?;
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtAck => writer.write_u8(0xdd)?,
|
Packet::CoreMgmtReply { succeeded } => {
|
||||||
Packet::CoreMgmtNack => writer.write_u8(0xde)?,
|
writer.write_u8(0xe0)?;
|
||||||
|
writer.write_bool(succeeded)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ mod remote_coremgmt {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Ok(Packet::CoreMgmtAck) => {
|
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ mod remote_coremgmt {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Ok(Packet::CoreMgmtAck) => {
|
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ mod remote_coremgmt {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Ok(Packet::CoreMgmtAck) => {
|
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ mod remote_coremgmt {
|
||||||
data: *slice,
|
data: *slice,
|
||||||
},
|
},
|
||||||
|reply| match reply {
|
|reply| match reply {
|
||||||
Packet::CoreMgmtAck => Ok(()),
|
Packet::CoreMgmtReply { succeeded: true } => Ok(()),
|
||||||
packet => {
|
packet => {
|
||||||
error!("received unexpected aux packet: {:?}", packet);
|
error!("received unexpected aux packet: {:?}", packet);
|
||||||
Err(drtio::Error::UnexpectedReply)
|
Err(drtio::Error::UnexpectedReply)
|
||||||
|
@ -488,7 +488,7 @@ mod remote_coremgmt {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Ok(Packet::CoreMgmtAck) => {
|
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ mod remote_coremgmt {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Ok(Packet::CoreMgmtAck) => {
|
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,7 @@ mod remote_coremgmt {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Ok(Packet::CoreMgmtAck) => {
|
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
|
||||||
write_i8(stream, Reply::RebootImminent as i8).await?;
|
write_i8(stream, Reply::RebootImminent as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -600,7 +600,7 @@ mod remote_coremgmt {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Ok(Packet::CoreMgmtAck) => {
|
Ok(Packet::CoreMgmtReply { succeeded: true }) => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1055,7 +1055,7 @@ fn process_aux_packet(
|
||||||
timer
|
timer
|
||||||
);
|
);
|
||||||
mgmt::clear_log();
|
mgmt::clear_log();
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtSetLogLevelRequest {
|
drtioaux::Packet::CoreMgmtSetLogLevelRequest {
|
||||||
destination: _destination,
|
destination: _destination,
|
||||||
|
@ -1075,9 +1075,9 @@ fn process_aux_packet(
|
||||||
if let Ok(level_filter) = mgmt::byte_to_level_filter(log_level) {
|
if let Ok(level_filter) = mgmt::byte_to_level_filter(log_level) {
|
||||||
info!("Changing log level to {}", level_filter);
|
info!("Changing log level to {}", level_filter);
|
||||||
log::set_max_level(level_filter);
|
log::set_max_level(level_filter);
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })
|
||||||
} else {
|
} else {
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtSetUartLogLevelRequest {
|
drtioaux::Packet::CoreMgmtSetUartLogLevelRequest {
|
||||||
|
@ -1103,9 +1103,9 @@ fn process_aux_packet(
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.set_uart_log_level(level_filter);
|
.set_uart_log_level(level_filter);
|
||||||
}
|
}
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })
|
||||||
} else {
|
} else {
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtConfigReadRequest {
|
drtioaux::Packet::CoreMgmtConfigReadRequest {
|
||||||
|
@ -1129,7 +1129,7 @@ fn process_aux_packet(
|
||||||
let key_slice = &key[..length as usize];
|
let key_slice = &key[..length as usize];
|
||||||
if !key_slice.is_ascii() {
|
if !key_slice.is_ascii() {
|
||||||
error!("invalid key");
|
error!("invalid key");
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
|
||||||
} else {
|
} else {
|
||||||
let key = core::str::from_utf8(key_slice).unwrap();
|
let key = core::str::from_utf8(key_slice).unwrap();
|
||||||
if core_manager.fetch_config_value(key).is_ok() {
|
if core_manager.fetch_config_value(key).is_ok() {
|
||||||
|
@ -1143,7 +1143,7 @@ fn process_aux_packet(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1197,11 +1197,7 @@ fn process_aux_packet(
|
||||||
core_manager.clear_data();
|
core_manager.clear_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
if succeeded {
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded })
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
|
|
||||||
} else {
|
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtConfigRemoveRequest {
|
drtioaux::Packet::CoreMgmtConfigRemoveRequest {
|
||||||
destination: _destination,
|
destination: _destination,
|
||||||
|
@ -1222,14 +1218,11 @@ fn process_aux_packet(
|
||||||
let key_slice = &key[..length as usize];
|
let key_slice = &key[..length as usize];
|
||||||
if !key_slice.is_ascii() {
|
if !key_slice.is_ascii() {
|
||||||
error!("invalid key");
|
error!("invalid key");
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
|
||||||
} else {
|
} else {
|
||||||
let key = core::str::from_utf8(key_slice).unwrap();
|
let key = core::str::from_utf8(key_slice).unwrap();
|
||||||
if core_manager.remove_config(key).is_ok() {
|
let succeeded = core_manager.remove_config(key).is_ok();
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded })
|
||||||
} else {
|
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtConfigEraseRequest {
|
drtioaux::Packet::CoreMgmtConfigEraseRequest {
|
||||||
|
@ -1247,7 +1240,7 @@ fn process_aux_packet(
|
||||||
);
|
);
|
||||||
|
|
||||||
error!("config erase not supported on zynq device");
|
error!("config erase not supported on zynq device");
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtRebootRequest {
|
drtioaux::Packet::CoreMgmtRebootRequest {
|
||||||
destination: _destination,
|
destination: _destination,
|
||||||
|
@ -1264,7 +1257,7 @@ fn process_aux_packet(
|
||||||
timer
|
timer
|
||||||
);
|
);
|
||||||
|
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)?;
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })?;
|
||||||
info!("reboot imminent");
|
info!("reboot imminent");
|
||||||
slcr::reboot();
|
slcr::reboot();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1284,7 +1277,7 @@ fn process_aux_packet(
|
||||||
);
|
);
|
||||||
|
|
||||||
error!("debug allocator not supported on zynq device");
|
error!("debug allocator not supported on zynq device");
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false })
|
||||||
}
|
}
|
||||||
|
|
||||||
p => {
|
p => {
|
||||||
|
|
Loading…
Reference in New Issue