Support CoreMgmt over DRTIO on Zynq Devices #323

Merged
sb10q merged 27 commits from occheung/artiq-zynq:drtio-coremgmt into master 2024-11-19 18:55:03 +08:00
2 changed files with 11 additions and 11 deletions
Showing only changes of commit 5cb565a7e0 - Show all commits

View File

@ -1190,12 +1190,12 @@ fn process_aux_packet(
timer timer
); );
core_manager.add_data(&data, length as usize); core_manager.add_config_data(&data, length as usize);
let mut succeeded = true; let mut succeeded = true;
if last { if last {
succeeded = core_manager.write_config().is_ok(); succeeded = core_manager.write_config().is_ok();
core_manager.clear_data(); core_manager.clear_config_data();
} }
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded }) drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded })

View File

@ -46,7 +46,7 @@ pub fn clear_log() {
pub struct Manager<'a> { pub struct Manager<'a> {
cfg: &'a mut Config, cfg: &'a mut Config,
last_log: Sliceable, last_log: Sliceable,
current_payload: Cursor<Vec<u8>>, config_payload: Cursor<Vec<u8>>,
last_value: Sliceable, last_value: Sliceable,
} }
@ -55,7 +55,7 @@ impl<'a> Manager<'_> {
Manager { Manager {
cfg: cfg, cfg: cfg,
last_log: Sliceable::new(0, Vec::new()), last_log: Sliceable::new(0, Vec::new()),
current_payload: Cursor::new(Vec::new()), config_payload: Cursor::new(Vec::new()),
last_value: Sliceable::new(0, Vec::new()), last_value: Sliceable::new(0, Vec::new()),
} }
} }
@ -83,22 +83,22 @@ impl<'a> Manager<'_> {
self.last_value.get_slice_satellite(data_slice) self.last_value.get_slice_satellite(data_slice)
} }
pub fn add_data(&mut self, data: &[u8], data_len: usize) { pub fn add_config_data(&mut self, data: &[u8], data_len: usize) {
self.current_payload.write_all(&data[..data_len]).unwrap(); self.config_payload.write_all(&data[..data_len]).unwrap();
} }
pub fn clear_data(&mut self) { pub fn clear_config_data(&mut self) {
self.current_payload.get_mut().clear(); self.config_payload.get_mut().clear();
self.current_payload.set_position(0); self.config_payload.set_position(0);
} }
pub fn write_config(&mut self) -> Result<()> { pub fn write_config(&mut self) -> Result<()> {
let key = self let key = self
.current_payload .config_payload
.read_string() .read_string()
.map_err(|_err| error!("error on reading key"))?; .map_err(|_err| error!("error on reading key"))?;
debug!("write key: {}", key); debug!("write key: {}", key);
let value = self.current_payload.read_bytes().unwrap(); let value = self.config_payload.read_bytes().unwrap();
self.cfg self.cfg
.write(&key, value) .write(&key, value)