From 83da524ad29835010d110d6d6d85ede88b64888b Mon Sep 17 00:00:00 2001 From: occheung Date: Thu, 19 Sep 2024 17:15:01 +0800 Subject: [PATCH] satman mgmt: allow sliceable to consume log source --- src/satman/src/main.rs | 5 +---- src/satman/src/mgmt.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/satman/src/main.rs b/src/satman/src/main.rs index 7cfcb22..1a1804e 100644 --- a/src/satman/src/main.rs +++ b/src/satman/src/main.rs @@ -1030,10 +1030,7 @@ fn process_aux_packet( timer ); let mut data_slice = [0; SAT_PAYLOAD_MAX_SIZE]; - let meta = core_manager.log_get_slice(&mut data_slice); - if clear && meta.status.is_first() { - mgmt::clear_log(); - } + let meta = core_manager.log_get_slice(&mut data_slice, clear); drtioaux::send( 0, &drtioaux::Packet::CoreMgmtGetLogReply { diff --git a/src/satman/src/mgmt.rs b/src/satman/src/mgmt.rs index 179d701..80ca733 100644 --- a/src/satman/src/mgmt.rs +++ b/src/satman/src/mgmt.rs @@ -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 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)