Skip to content

Commit c298c42

Browse files
Merge pull request #93 from FrameworkComputer/camera-ignore
camera: Don't crash if something's wrong
2 parents c7903a3 + 35b4d4e commit c298c42

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: framework_lib/src/camera.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pub const FRAMEWORK13_16_2ND_GEN_PID: u16 = 0x001C;
33
pub const FRAMEWORK12_PID: u16 = 0x001D;
44

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

22-
let dev_descriptor = dev.device_descriptor().unwrap();
22+
let dev_descriptor = dev.device_descriptor()?;
2323
let i_product = dev_descriptor
2424
.product_string_index()
2525
.and_then(|x| handle.read_string_descriptor_ascii(x).ok());
2626
println!("{}", i_product.unwrap_or_default());
2727
println!(" Firmware Version: {}", dev_descriptor.device_version());
2828
}
29+
Ok(())
2930
}

Diff for: framework_lib/src/commandline/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ fn print_versions(ec: &CrosEc) {
473473
}
474474
}
475475
#[cfg(feature = "rusb")]
476-
check_camera_version();
476+
let _ignore_err = check_camera_version();
477477
}
478478

479479
fn print_esrt() {

0 commit comments

Comments
 (0)