From 759cca3bfd24c81fae8db28a08f45c03bb0194d5 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 1bd6db34..4e4e8daf 100644 --- a/src/satman/src/main.rs +++ b/src/satman/src/main.rs @@ -1031,10 +1031,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 179d7011..80ca7330 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)