Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

orb-mcu-util: hardware revision #276

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading