diff --git a/src/bmp280.rs b/src/bmp280.rs index bd658008b..dfe67c9c4 100644 --- a/src/bmp280.rs +++ b/src/bmp280.rs @@ -110,7 +110,9 @@ mod tests { #[test] fn test_bmp280_pi_4() { - let mut baro = Bmp280Device::builder().build().unwrap(); + let mut baro = Bmp280Device::builder().build().unwrap_or_else(|error| { + panic!("Failed to build BMP280: {error}"); + }); for _ in 0..10 { println!("BMP280 temperature: {:?}", baro.read_temperature()); println!("BMP280 pressure: {:?}", baro.read_pressure()); diff --git a/src/icm20689.rs b/src/icm20689.rs index 600daf79e..80e6d00d2 100644 --- a/src/icm20689.rs +++ b/src/icm20689.rs @@ -123,7 +123,9 @@ mod tests { #[test] fn test_icm20689_pi_4() { - let mut imu = Icm20689Device::builder().build().unwrap(); + let mut imu = Icm20689Device::builder().build().unwrap_or_else(|error| { + panic!("Failed to build ICM20689: {error:?}"); + }); for _ in 0..10 { println!("ICM20689 gyroscope: {:?}", imu.read_angular_velocity()); println!("ICM20689 accelerometers: {:?}", imu.read_acceleration()); diff --git a/src/leak.rs b/src/leak.rs index b33d4dae4..53c0c894a 100644 --- a/src/leak.rs +++ b/src/leak.rs @@ -82,7 +82,9 @@ mod tests { #[test] fn test_leak_pi_4() { - let leak = LeakDetector::builder().build().unwrap(); + let leak = LeakDetector::builder().build().unwrap_or_else(|error| { + panic!("Failed to build leak detector: {error:?}"); + }); for _ in 0..10 { println!("Leak detector: {}", leak.is_leak_detected().unwrap()); sleep(Duration::from_millis(1000)); diff --git a/src/pca9685.rs b/src/pca9685.rs index daf301f2d..78e63680f 100644 --- a/src/pca9685.rs +++ b/src/pca9685.rs @@ -191,18 +191,34 @@ mod tests { //TODO: Not working #[test] fn test_pca9685_pi_4() { - let mut pwm = Pca9685Device::builder().build().unwrap(); + let mut pwm = Pca9685Device::builder().build().unwrap_or_else(|error| { + panic!("Error building PCA9685: {error:?}"); + }); + println!("PCA9685: Start initial configuration"); - pwm.enable_output(false).unwrap(); - pwm.set_frequency(60.0).unwrap(); - pwm.set_duty_cycle_all(0.5).unwrap(); + + pwm.enable_output(false).unwrap_or_else(|error| { + panic!("Error in while enabling output: {error:?}"); + }); + pwm.set_frequency(60.0).unwrap_or_else(|error| { + panic!("Error in setting frequency: {error:?}"); + }); + pwm.set_duty_cycle_all(0.5).unwrap_or_else(|error| { + panic!("Error in configuring duty cycle: {error:?}"); + }); + println!("PCA9685: Enabling PWM output"); - pwm.enable_output(true).unwrap(); + pwm.enable_output(true).unwrap_or_else(|error| { + panic!("Error in enabling output: {error:?}"); + }); sleep(Duration::from_millis(1000)); for duty_cycle in [0.0, 1.0, 0.0, 1.0, 0.5] { for channel in 0..16 { println!("PCA9685: Channel {channel} value {duty_cycle:.1}"); - pwm.set_duty_cycle(channel, duty_cycle).unwrap(); + pwm.set_duty_cycle(channel, duty_cycle) + .unwrap_or_else(|error| { + panic!("Error in setting duty cycle: {error:?}"); + }); sleep(Duration::from_millis(100)); } }