From 7b313028ea2959a64acbdcf951036eda140b025d Mon Sep 17 00:00:00 2001 From: Cyril Fougeray Date: Mon, 17 Jun 2024 19:59:42 +0200 Subject: [PATCH] orb-mcu-util: don't fail on building boards object (#136) * orb-mcu-util: don't fail on building boards object heartbeat is sent to check that mcu is alive but if it's not, don't fail because the command might be targeted to the other MCU * orb-mcu-util: error trace prettify * address comments --------- Co-authored-by: Ryan Butler --- mcu-util/src/orb/main_board.rs | 14 ++++++++++++-- mcu-util/src/orb/security_board.rs | 20 +++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/mcu-util/src/orb/main_board.rs b/mcu-util/src/orb/main_board.rs index ffe7864c..74612653 100644 --- a/mcu-util/src/orb/main_board.rs +++ b/mcu-util/src/orb/main_board.rs @@ -66,7 +66,7 @@ impl MainBoardBuilder { // Send a heartbeat to the main mcu to ensure it is alive // & "subscribe" to the main mcu messages: messages to the Jetson // are going to be sent after the heartbeat - canfd_iface + let ack_result = canfd_iface .send(McuPayload::ToMain( main_messaging::jetson_to_mcu::Payload::Heartbeat( main_messaging::Heartbeat { @@ -74,7 +74,17 @@ impl MainBoardBuilder { }, ), )) - .await?; + .await + .map(|c| { + if let CommonAckError::Success = c { + Ok(()) + } else { + Err(eyre!("ack error: {c}")) + } + }); + if let Err(e) = ack_result { + error!("Failed to send heartbeat to main mcu: {:#?}", e); + } Ok(( MainBoard { diff --git a/mcu-util/src/orb/security_board.rs b/mcu-util/src/orb/security_board.rs index 074c74c1..7e534435 100644 --- a/mcu-util/src/orb/security_board.rs +++ b/mcu-util/src/orb/security_board.rs @@ -61,7 +61,7 @@ impl SecurityBoardBuilder { // Send a heartbeat to the mcu to ensure it is alive // & "subscribe" to the mcu messages: messages to the Jetson // are going to be sent after the heartbeat - canfd_iface + let ack_result = canfd_iface .send(McuPayload::ToSec( security_messaging::jetson_to_sec::Payload::Heartbeat( security_messaging::Heartbeat { @@ -69,7 +69,17 @@ impl SecurityBoardBuilder { }, ), )) - .await?; + .await + .map(|c| { + if let CommonAckError::Success = c { + Ok(()) + } else { + Err(eyre!("ack error: {c}")) + } + }); + if let Err(e) = ack_result { + error!("Failed to send heartbeat to security mcu: {:#?}", e); + } Ok(( SecurityBoard { @@ -369,7 +379,7 @@ impl SecurityBoardInfo { .await { is_err = true; - error!("Failed to fetch firmware versions: {:?}", e); + error!("Failed to fetch firmware versions: {:#?}", e); } if let Err(e) = sec_board @@ -385,7 +395,7 @@ impl SecurityBoardInfo { .await { is_err = true; - error!("Failed to fetch hardware versions: {:?}", e); + error!("Failed to fetch hardware versions: {:#?}", e); } if let Err(e) = sec_board @@ -401,7 +411,7 @@ impl SecurityBoardInfo { .await { is_err = true; - error!("Failed to fetch battery status: {:?}", e); + error!("Failed to fetch battery status: {:#?}", e); } match tokio::time::timeout(