Skip to content

Commit

Permalink
orb-mcu-util: hardware revision (#276)
Browse files Browse the repository at this point in the history
error out on unknown hardware revision,
and don't write into file.
  • Loading branch information
fouge authored Oct 22, 2024
1 parent 00afb2d commit 95210dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mcu-util/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use clap::{
};
use color_eyre::eyre::{Context, Result};
use orb_build_info::{make_build_info, BuildInfo};
use orb_mcu_interface::orb_messages::mcu_main::hardware::OrbVersion;
use tokio::fs;
use tokio::fs::OpenOptions;
use tokio::io::AsyncWriteExt;
Expand Down Expand Up @@ -165,6 +166,12 @@ async fn execute(args: Args) -> Result<()> {
}
SubCommand::HardwareRevision { filename } => {
let hw_rev = orb.get_revision().await?;
// discard operation if unknown hardware version
if hw_rev.0.version == i32::from(OrbVersion::HwVersionUnknown) {
return Err(color_eyre::eyre::eyre!(
"Failed to fetch hardware revision: unknown"
));
}
match filename {
None => {
println!("{}", hw_rev);
Expand Down
4 changes: 4 additions & 0 deletions mcu-util/src/orb/revision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pub struct OrbRevision(pub main_messaging::Hardware);
impl Display for OrbRevision {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
if self.0.version
== i32::from(main_messaging::hardware::OrbVersion::HwVersionUnknown)
{
write!(f, "unknown")
} else if self.0.version
< main_messaging::hardware::OrbVersion::HwVersionDiamondPoc1 as i32
{
write!(f, "EVT{:?}", self.0.version)
Expand Down

0 comments on commit 95210dc

Please sign in to comment.