satman mgmt: allow sliceable to consume log source

This commit is contained in:
occheung 2024-09-19 17:15:01 +08:00
parent 349e537626
commit 83da524ad2
2 changed files with 7 additions and 6 deletions

View File

@ -1030,10 +1030,7 @@ fn process_aux_packet(
timer timer
); );
let mut data_slice = [0; SAT_PAYLOAD_MAX_SIZE]; let mut data_slice = [0; SAT_PAYLOAD_MAX_SIZE];
let meta = core_manager.log_get_slice(&mut data_slice); let meta = core_manager.log_get_slice(&mut data_slice, clear);
if clear && meta.status.is_first() {
mgmt::clear_log();
}
drtioaux::send( drtioaux::send(
0, 0,
&drtioaux::Packet::CoreMgmtGetLogReply { &drtioaux::Packet::CoreMgmtGetLogReply {

View File

@ -60,10 +60,14 @@ impl<'a> Manager<'_> {
} }
} }
pub fn log_get_slice(&mut self, data_slice: &mut [u8; SAT_PAYLOAD_MAX_SIZE]) -> SliceMeta { pub fn log_get_slice(&mut self, data_slice: &mut [u8; SAT_PAYLOAD_MAX_SIZE], consume: bool) -> SliceMeta {
// Populate buffer if depleted // Populate buffer if depleted
if self.last_log.at_end() { if self.last_log.at_end() {
self.last_log.extend(get_logger_buffer().extract().as_bytes()); let mut buffer = get_logger_buffer();
self.last_log.extend(buffer.extract().as_bytes());
if consume {
buffer.clear();
}
} }
self.last_log.get_slice_satellite(data_slice) self.last_log.get_slice_satellite(data_slice)