diff --git a/mcu-util/src/main.rs b/mcu-util/src/main.rs index 143d9a3f..44b4ed08 100644 --- a/mcu-util/src/main.rs +++ b/mcu-util/src/main.rs @@ -199,7 +199,7 @@ async fn main() -> Result<()> { } if let Err(e) = execute(args).await { - error!("{}", e); + error!("{:#?}", e); std::process::exit(-1); } else { std::process::exit(0); diff --git a/mcu-util/src/orb/main_board.rs b/mcu-util/src/orb/main_board.rs index a01d66fa..3d95bae3 100644 --- a/mcu-util/src/orb/main_board.rs +++ b/mcu-util/src/orb/main_board.rs @@ -1,5 +1,5 @@ use async_trait::async_trait; -use eyre::{eyre, Result}; +use eyre::{eyre, Context, Result}; use orb_messages::{mcu_main as main_messaging, CommonAckError}; use std::ops::Sub; use std::sync::mpsc; @@ -21,8 +21,9 @@ const REBOOT_DELAY: u32 = 3; pub struct MainBoard { canfd_iface: CanRawMessaging, isotp_iface: CanIsoTpMessaging, + /// Optional serial interface for the main board, if available (ie orb-ui might own it) #[allow(dead_code)] - serial_iface: SerialMessaging, + serial_iface: Option, message_queue_rx: mpsc::Receiver, } @@ -46,16 +47,18 @@ impl MainBoardBuilder { String::from("can0"), Device::Main, self.message_queue_tx.clone(), - )?; + ) + .wrap_err("Failed to create CanRawMessaging for MainBoard")?; let isotp_iface = CanIsoTpMessaging::new( String::from("can0"), IsoTpNodeIdentifier::JetsonApp7, IsoTpNodeIdentifier::MainMcu, self.message_queue_tx.clone(), - )?; + ) + .wrap_err("Failed to create CanIsoTpMessaging for MainBoard")?; - let serial_iface = SerialMessaging::new(Device::Main)?; + let serial_iface = SerialMessaging::new(Device::Main).ok(); // Send a heartbeat to the main mcu to ensure it is alive // & "subscribe" to the main mcu messages: messages to the Jetson @@ -325,8 +328,9 @@ impl MainBoardInfo { /// Fetches `MainBoardInfo` from the main board /// on timeout, returns the info that was fetched so far - async fn build(mut self, main: &mut MainBoard) -> Result { - main.isotp_iface + async fn build(mut self, main_board: &mut MainBoard) -> Result { + main_board + .isotp_iface .send(McuPayload::ToMain( main_messaging::jetson_to_mcu::Payload::ValueGet( main_messaging::ValueGet { @@ -336,7 +340,8 @@ impl MainBoardInfo { ), )) .await?; - main.isotp_iface + main_board + .isotp_iface .send(McuPayload::ToMain( main_messaging::jetson_to_mcu::Payload::ValueGet( main_messaging::ValueGet { @@ -346,7 +351,8 @@ impl MainBoardInfo { ), )) .await?; - main.isotp_iface + main_board + .isotp_iface .send(McuPayload::ToMain( main_messaging::jetson_to_mcu::Payload::ValueGet( main_messaging::ValueGet { @@ -364,7 +370,7 @@ impl MainBoardInfo { }; loop { if let Ok(McuPayload::FromMain(main_mcu_payload)) = - main.message_queue_rx.recv_timeout(timeout) + main_board.message_queue_rx.recv_timeout(timeout) { match main_mcu_payload { main_messaging::mcu_to_jetson::Payload::Versions(v) => { diff --git a/mcu-util/src/orb/security_board.rs b/mcu-util/src/orb/security_board.rs index 16b8430c..c6d6eaeb 100644 --- a/mcu-util/src/orb/security_board.rs +++ b/mcu-util/src/orb/security_board.rs @@ -1,5 +1,5 @@ use async_trait::async_trait; -use eyre::{eyre, Result}; +use eyre::{eyre, Context, Result}; use orb_messages::mcu_sec::battery_status::BatteryState; use orb_messages::{mcu_sec as security_messaging, CommonAckError}; use std::ops::Sub; @@ -43,14 +43,16 @@ impl SecurityBoardBuilder { String::from("can0"), Device::Security, self.message_queue_tx.clone(), - )?; + ) + .wrap_err("Failed to create CanRawMessaging for SecurityBoard")?; let isotp_iface = CanIsoTpMessaging::new( String::from("can0"), IsoTpNodeIdentifier::JetsonApp7, IsoTpNodeIdentifier::SecurityMcu, self.message_queue_tx.clone(), - )?; + ) + .wrap_err("Failed to create CanIsoTpMessaging for SecurityBoard")?; // Send a heartbeat to the mcu to ensure it is alive // & "subscribe" to the mcu messages: messages to the Jetson