aquarium_control/sensors/
dht_error.rs1use thiserror::Error;
10#[derive(Debug, Error)]
11pub enum DhtError {
13 #[cfg(all(target_os = "linux", feature = "target_hw"))]
15 #[error(
16 "[{location}] Could not get pin {vcc_pin_nr} from GPIO interface for DHT power supply."
17 )]
18 VccPinAcquisitionFailed {
19 location: String,
20 vcc_pin_nr: u8,
21
22 #[source]
23 source: rppal::gpio::Error,
24 },
25
26 #[cfg(all(target_os = "linux", feature = "target_hw"))]
28 #[error("[{location}] Failure to acquire pin {data_pin_nr} for triggering DHT sensor")]
29 DataPinOutputAcquisitionFailed {
30 location: String,
31 data_pin_nr: u8,
32
33 #[source]
34 source: rppal::gpio::Error,
35 },
36
37 #[cfg(all(target_os = "linux", feature = "target_hw"))]
39 #[error("[{location}] Failure to acquire pin {input_pin_nr} for reading from DHT sensor")]
40 DataPinInputAcquisitionFailed {
41 location: String,
42 input_pin_nr: u8,
43
44 #[source]
45 source: rppal::gpio::Error,
46 },
47
48 #[cfg(all(target_os = "linux", feature = "target_hw"))]
50 #[error("[{0}] Could not set interrupt")]
51 CouldNotSetInterrupt(String),
52
53 #[cfg(all(target_os = "linux", feature = "target_hw"))]
55 #[error("[{0}] Could not clear the interrupt")]
56 CouldNotClearInterrupt(String),
57
58 #[cfg(all(target_os = "linux", feature = "target_hw"))]
60 #[error("[{0}] Execution of interrupt failed")]
61 InterruptFailed(String),
62
63 #[cfg(all(target_os = "linux", feature = "target_hw"))]
65 #[error("[{0}] Incorrect number of valid ticks received: target={1}, measured={2}.")]
66 WrongNumberOfValidTicks(String, usize, usize),
67
68 #[error("[{0}] Calculated checksum ({1}) does not match the received value ({2})")]
70 ChecksumError(String, u8, u8),
71
72 #[allow(unused)]
74 #[error("[{0}] Timeout during transmission of data")]
75 Timeout(String),
76
77 #[error("[{0}] The temperature value is out of range (measured {1}, limits are {2}, {3})")]
79 TemperatureOutOfRange(String, f32, f32, f32),
80
81 #[error("[{0}] The humidity is out of range (measured {1}, limits are {2}, {3})")]
83 HumidityOutOfRange(String, f32, f32, f32),
84
85 #[allow(unused)] #[error("[{0}] Gpio handle has not been provided. Check the configuration.")]
88 GpioHandleNotProvided(String),
89
90 #[allow(unused)] #[error("[{0}] Dht driver has not been compiled into the SW for this platform.")]
93 IncorrectPlatform(String),
94
95 #[allow(unused)] #[error("[{location}] Failed to read from DHT sensor (after {retry_counter} retries")]
98 FailedAfterRetries {
99 location: String,
100 retry_counter: u64,
101
102 #[source]
103 source: Box<DhtError>,
104 },
105}