From 45569e8fb5d951a2468d67fd366e160394134704 Mon Sep 17 00:00:00 2001 From: lkoester Date: Wed, 15 Feb 2023 14:57:43 +0100 Subject: [PATCH] cleaned up debug messages --- output.log | 17 ++++++++ src/aocs_handler.rs | 4 +- src/can.rs | 6 +-- src/ccsds.rs | 3 +- src/main.rs | 99 ++------------------------------------------ src/pld_handler.rs | 22 +++++----- src/power_handler.rs | 6 +-- src/pus.rs | 5 ++- 8 files changed, 43 insertions(+), 119 deletions(-) diff --git a/output.log b/output.log index 45c1aaf..675608e 100644 --- a/output.log +++ b/output.log @@ -18,3 +18,20 @@ [2023-02-15][11:11:37][main][INFO] Starting TMTC task [2023-02-15][11:11:37][main][INFO] Starting power task [2023-02-15][11:11:37][main][INFO] Starting AOCS task +[2023-02-15][14:42:44][main][INFO] Starting TMTC task +[2023-02-15][14:42:44][main][INFO] Starting power task +[2023-02-15][14:42:44][main][INFO] Starting Payload Handling task +[2023-02-15][14:42:44][main][INFO] Starting TM funnel task +[2023-02-15][14:42:44][main][INFO] Starting AOCS task +[2023-02-15][14:43:13][main][INFO] Running DemoSat OBSW +[2023-02-15][14:43:13][main][INFO] Starting TMTC task +[2023-02-15][14:43:13][main][INFO] Starting power task +[2023-02-15][14:43:13][main][INFO] Starting Payload Handling task +[2023-02-15][14:43:13][main][INFO] Starting TM funnel task +[2023-02-15][14:43:13][main][INFO] Starting AOCS task +[2023-02-15][14:48:12][main][INFO] Running DemoSat OBSW! +[2023-02-15][14:48:12][main][INFO] Starting TMTC task +[2023-02-15][14:48:12][main][INFO] Starting power task +[2023-02-15][14:48:12][main][INFO] Starting Payload Handling task +[2023-02-15][14:48:12][main][INFO] Starting TM funnel task +[2023-02-15][14:48:12][main][INFO] Starting AOCS task diff --git a/src/aocs_handler.rs b/src/aocs_handler.rs index af6a932..c226100 100644 --- a/src/aocs_handler.rs +++ b/src/aocs_handler.rs @@ -160,9 +160,7 @@ impl MGMHandler { pub fn handle_hk_request(&mut self, hk_req: HkRequest) { match hk_req { - HkRequest::OneShot(_) => { - - } + HkRequest::OneShot(_) => {} HkRequest::Enable(_) => {} HkRequest::Disable(_) => {} HkRequest::ModifyCollectionInterval(_, _) => {} diff --git a/src/can.rs b/src/can.rs index 80b1dea..de33c77 100644 --- a/src/can.rs +++ b/src/can.rs @@ -3,7 +3,7 @@ use crate::can_ids::{ PackageModel, SenderReceiverThread, ThreadId, }; use embedded_can::{self, Frame}; -use log::{info, warn}; +use log::{debug, warn}; use socketcan::{errors, frame, socket, CanFrame, Socket}; use std::collections::HashMap; use std::io; @@ -55,13 +55,13 @@ impl CanRxHandler { pub fn rx_socket(&self) -> Option { let frame = self.socket.read_frame().ok()?; - info!("Can Frame read: {:?}.", frame); + debug!("Can Frame read: {:?}.", frame); return Some(frame); } pub fn forward_frame(&self, frame: CanFrame) { let frame_id = can_id_to_package_id(frame.id()); - info!("Frame forwarding with id: {:?}", frame_id); + debug!("Frame forwarding with id: {:?}", frame_id); if let Some(frame_id) = frame_id { if self.package_map.contains_key(&frame_id) { let value = self.package_map.get(&frame_id).unwrap(); diff --git a/src/ccsds.rs b/src/ccsds.rs index 1a5bb76..7f4807a 100644 --- a/src/ccsds.rs +++ b/src/ccsds.rs @@ -1,3 +1,4 @@ +use log::warn; use crate::tmtc::{MpscStoreAndSendError, PusTcSource, PUS_APID}; use satrs_core::spacepackets::{CcsdsPacket, SpHeader}; use satrs_core::tmtc::{CcsdsPacketHandler, ReceivesCcsdsTc}; @@ -29,7 +30,7 @@ impl CcsdsPacketHandler for CcsdsReceiver { sp_header: &SpHeader, _tc_raw: &[u8], ) -> Result<(), Self::Error> { - println!("Unknown APID 0x{:x?} detected", sp_header.apid()); + warn!("Unknown APID 0x{:x?} detected", sp_header.apid()); Ok(()) } } diff --git a/src/main.rs b/src/main.rs index 0ff32bb..50f3b7b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,9 +84,8 @@ impl EcssTmSenderCore for EventTmSender { } fn main() { - println!("Running SESPSat OBSW"); - logger::setup_logger().unwrap(); + info!("Running DemoSat OBSW!"); let tm_pool = LocalPool::new(PoolCfg::new(vec![ (30, 32), @@ -244,98 +243,6 @@ fn main() { ); }); - /* - // AOCS Thread - let socket1 = - can::CanTxHandler::new_socket("can0", ThreadId::AOCSThread, package_map_aocs_tx).unwrap(); - info!("Starting AOCS receiving thread"); - let builder2 = thread::Builder::new().name("AOCSThread".into()); - let jh2 = builder2.spawn(move || { - let mut time_stamp_buf: [u8; 7] = [0; 7]; - let mut huge_buf: [u8; 8192] = [0; 8192]; - let data: [u8; 3] = [1, 2, 3]; - let current_mgm_data = MgmData::default(); - //let current_mgt_data = MgtData::default(); - //let current_ - loop { - // device handling - //info!("Sending {:?}", PackageId::AOCSControlMGT1); - //socket1.tx_socket(PackageId::AOCSControlMGT1, &data); - //info!("Waiting for {:?}", PackageId::AOCSDataMGM1); - let msg = aocs_can_rx.try_recv(); - //current_mgm_data.x = new_data - match aocs_can_rx.try_recv() { - Ok(package) => match package.package_id() { - _ => warn!("Incorrect Id"), - }, - Err(_) => {} - } - - // telecommand handling - match acs_thread_rx.try_recv() { - Ok(request_with_token) => { - match request_with_token.0 { - Request::HkRequest(hk_req) => { - match hk_req { - HkRequest::OneShot(id) => { - assert_eq!(id.target_id, RequestTargetId::AcsSubsystem as u32); - if id.unique_id == 0 { - let mut sp_header = SpHeader::tm_unseg( - 0x02, - aocs_seq_count_provider.get_and_increment(), - 0, - ) - .unwrap(); - let cds_stamp = - TimeProvider::from_now_with_u16_days().unwrap(); - cds_stamp.write_to_bytes(&mut time_stamp_buf); - let mut len = id.write_to_be_bytes(&mut huge_buf).unwrap(); - let json_string = "asdf"; - huge_buf[8..json_string.len() + 8] - .copy_from_slice(json_string.as_bytes()); - len += json_string.len(); - let tm_sec_header = PusTmSecondaryHeader::new_simple( - 3, - Subservice::TmHkPacket as u8, - &time_stamp_buf, - ); - let hk_tm = PusTm::new( - &mut sp_header, - tm_sec_header, - Some(&huge_buf[0..len]), - true, - ); - let addr = aocs_tm_store.add_pus_tm(&hk_tm); - aocs_tm_funnel_tx.send(addr).expect("sending failed"); - /* let start_token = self //implement this for verification - .verif_reporter - .start_success(token, &self.time_stamp) - .expect("Error sending start success"); - self.tm_tx - .send(addr) - .expect("Sending TM to TM funnel failed"); - self.verif_reporter - .completion_success(start_token, &self.time_stamp) - .expect("Error sending completion success"); - - */ - } - } - HkRequest::Enable(_) => {} - HkRequest::Disable(_) => {} - HkRequest::ModifyCollectionInterval(_, _) => {} - } - } - _ => {} - } - } - Err(_) => {} - } - } - }); - - */ - let package_map_pld_tx = load_package_ids(); let pld_tm_funnel_tx = tm_funnel_tx.clone(); let pld_tm_store = tm_store.clone(); @@ -344,7 +251,7 @@ fn main() { can_tx_sender.clone(); //let mut pcdu_tx_clone = pcdu_tx.clone(); - println!("Starting Payload Handling task"); + info!("Starting Payload Handling task"); let builder3 = thread::Builder::new().name("PLDThread".into()); let jh3 = builder3.spawn(move || { core_pld_task( @@ -356,7 +263,7 @@ fn main() { ); }); - println!("Starting TM funnel task"); + info!("Starting TM funnel task"); let builder4 = thread::Builder::new().name("TMFunnelThread".into()); let jh4 = builder4.spawn(move || { let tm_funnel = TmFunnel { diff --git a/src/pld_handler.rs b/src/pld_handler.rs index d889964..e3699e2 100644 --- a/src/pld_handler.rs +++ b/src/pld_handler.rs @@ -3,7 +3,7 @@ use crate::can_ids::{DeviceId, PackageId, PackageModel}; use crate::power_handler::{DeviceState, PowerSwitcher}; use crate::requests::{Request, RequestWithToken}; use eurosim_obsw::RequestTargetId; -use log::info; +use log::{debug}; use satrs_core::power::{PowerSwitchInfo, PowerSwitcherCommandSender, SwitchId}; use satrs_core::pus::verification::{StdVerifSenderError, VerificationReporterWithSender}; use satrs_core::spacepackets::time::cds::TimeProvider; @@ -93,7 +93,7 @@ impl CameraHandler { .start_success(request_with_token.1, Some(&time_stamp_buf)) .expect("Error sending start success."); - info!("{:?}", camera_handler.get_mode()); + debug!("{:?}", camera_handler.get_mode()); while camera_handler.get_mode() != CameraMode::Idle { camera_handler.periodic_op(); } @@ -134,7 +134,7 @@ impl CameraHandler { .send_switch_on_cmd(self.camera_switch_id) .expect("sending switch cmd failed"); self.device_state = DeviceState::SwitchingPower; - info!("switching power"); + debug!("switching power"); } if self.device_state == DeviceState::SwitchingPower { if self @@ -143,18 +143,18 @@ impl CameraHandler { .expect("reading switch state failed") { self.device_state = DeviceState::On; - info!("device on"); + debug!("device on"); } } if self.device_state == DeviceState::On { self.can_tx.send(PackageModel::new(PackageId::CameraImageRequest, &[1]).unwrap()).unwrap(); - info!("sent camera request"); + debug!("sent camera request"); self.mode = CameraMode::Verification; } } CameraMode::Verification => { if self.device_state == DeviceState::On { - info!("waiting for image request confirmation"); + debug!("waiting for image request confirmation"); if let Ok(msg) = self.can_rx.recv() { if msg.package_id() == PackageId::CameraImageRequestConfirmation { self.mode = CameraMode::Start; @@ -164,7 +164,7 @@ impl CameraHandler { } CameraMode::Start => { if self.device_state == DeviceState::On { - info!("waiting for image start confirmation"); + debug!("waiting for image start confirmation"); if let Ok(msg) = self.can_rx.recv() { if msg.package_id() == PackageId::CameraImageExecutionStart { self.mode = CameraMode::End; @@ -174,14 +174,14 @@ impl CameraHandler { } CameraMode::End => { if self.device_state == DeviceState::On { - info!("waiting for image end confirmation"); + debug!("waiting for image end confirmation"); if let Ok(msg) = self.can_rx.recv() { if msg.package_id() == PackageId::CameraImageExectutionEnd { self.power_switcher .send_switch_off_cmd(self.camera_switch_id) .expect("sending switch command failed"); self.device_state = DeviceState::SwitchingPower; - info!("switching power"); + debug!("switching power"); } } } @@ -192,7 +192,7 @@ impl CameraHandler { .expect("reading switch state failed") { self.device_state = DeviceState::Off; - info!("device off"); + debug!("device off"); } } if self.device_state == DeviceState::Off { @@ -240,7 +240,7 @@ pub fn core_pld_task( .start_success(request_with_token.1, Some(&time_stamp_buf)) .expect("Error sending start success."); - info!("{:?}", camera_handler.get_mode()); + debug!("{:?}", camera_handler.get_mode()); while camera_handler.get_mode() != CameraMode::Idle { camera_handler.periodic_op(); } diff --git a/src/power_handler.rs b/src/power_handler.rs index e37b17a..b077dcf 100644 --- a/src/power_handler.rs +++ b/src/power_handler.rs @@ -1,5 +1,5 @@ use crate::can_ids::{DeviceId, PackageId, PackageModel}; -use log::info; +use log::{debug}; use satrs_core::power::{ PowerSwitchInfo, PowerSwitchProvider, PowerSwitcherCommandSender, SwitchId, SwitchState, }; @@ -145,7 +145,7 @@ impl PCDU { if msg.package_id() == PackageId::DevicePowerStatusResponse && msg.data()[0] == dev_id_bytes { - info!("received power status response"); + debug!("received power status response"); let mut map_lock = self.device_state_map.lock().unwrap(); let state: SwitchState; match msg.data()[1] { @@ -157,7 +157,7 @@ impl PCDU { } } *map_lock.get_mut(&dev_id).unwrap() = state; - info!("{:?}", map_lock); + debug!("{:?}", map_lock); Ok(()) } else { Err(()) diff --git a/src/pus.rs b/src/pus.rs index beaa952..6c4cd18 100644 --- a/src/pus.rs +++ b/src/pus.rs @@ -26,6 +26,7 @@ use satrs_core::pus::scheduling::PusScheduler; use std::collections::HashMap; use std::rc::Rc; use std::sync::mpsc::Sender; +use log::{debug}; pub struct PusReceiver { pub tm_helper: PusTmWithCdsShortHelper, @@ -108,8 +109,8 @@ impl PusServiceProvider for PusReceiver { impl PusReceiver { fn handle_test_service(&mut self, pus_tc: &PusTc, token: VerificationToken) { if PusPacket::subservice(pus_tc) == 1 { - println!("Received PUS ping command TC[17,1]"); - println!("Sending ping reply PUS TM[17,2]"); + debug!("Received PUS ping command TC[17,1]"); + debug!("Sending ping reply PUS TM[17,2]"); let ping_reply = self.tm_helper.create_pus_tm_timestamp_now(17, 2, None); let addr = self.tm_store.add_pus_tm(&ping_reply); let start_token = self