Skip to content

camera: Don't crash if something's wrong #93

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

Merged
merged 1 commit into from
Mar 24, 2025
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
5 changes: 3 additions & 2 deletions framework_lib/src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub const FRAMEWORK13_16_2ND_GEN_PID: u16 = 0x001C;
pub const FRAMEWORK12_PID: u16 = 0x001D;

/// Get and print the firmware version of the camera
pub fn check_camera_version() {
pub fn check_camera_version() -> Result<(), rusb::Error> {
for dev in rusb::devices().unwrap().iter() {
let dev_descriptor = dev.device_descriptor().unwrap();
if dev_descriptor.vendor_id() != FRAMEWORK_VID
Expand All @@ -19,11 +19,12 @@ pub fn check_camera_version() {
}
let handle = dev.open().unwrap();

let dev_descriptor = dev.device_descriptor().unwrap();
let dev_descriptor = dev.device_descriptor()?;
let i_product = dev_descriptor
.product_string_index()
.and_then(|x| handle.read_string_descriptor_ascii(x).ok());
println!("{}", i_product.unwrap_or_default());
println!(" Firmware Version: {}", dev_descriptor.device_version());
}
Ok(())
}
2 changes: 1 addition & 1 deletion framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ fn print_versions(ec: &CrosEc) {
}
}
#[cfg(feature = "rusb")]
check_camera_version();
let _ignore_err = check_camera_version();
}

fn print_esrt() {
Expand Down