Skip to content

Commit

Permalink
orb-mcu-util: don't fail on building boards object (#136)
Browse files Browse the repository at this point in the history
* 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 <thebutlah@gmail.com>
  • Loading branch information
fouge and TheButlah committed Jun 17, 2024
1 parent 3d369d9 commit 7b31302
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
14 changes: 12 additions & 2 deletions mcu-util/src/orb/main_board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,25 @@ 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 {
timeout_seconds: 0_u32,
},
),
))
.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 {
Expand Down
20 changes: 15 additions & 5 deletions mcu-util/src/orb/security_board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,25 @@ 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 {
timeout_seconds: 0_u32,
},
),
))
.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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 7b31302

Please sign in to comment.