pub enum SensorError {
Crc,
Invalid,
Identity,
}Expand description
What can go wrong turning a part’s raw bytes into a reading.
Most of these drivers only ever decode well-formed register values and so cannot fail, but parts that carry their own integrity check report a mismatch here so the caller re-reads rather than trusting corrupted data.
Variants§
Crc
A device’s own checksum did not match the bytes it covered, so the read was corrupted on the bus and must be repeated. Returned, for example, when a DS18B20 scratchpad’s CRC byte disagrees with the data bytes.
Invalid
A register field holds a code the datasheet leaves undefined, so the value cannot have come from a correctly working part. Returned, for example, when an HDC1080 configuration register carries the unassigned humidity-resolution code.
Identity
A device’s identification registers did not carry the values its datasheet fixes, so a different part, or nothing at all, answered at that address and its readings must not be trusted. Returned, for example, when an INA226’s manufacturer or die ID register reads something other than TI’s 0x5449 and 0x226.
Trait Implementations§
Source§impl Clone for SensorError
impl Clone for SensorError
Source§fn clone(&self) -> SensorError
fn clone(&self) -> SensorError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SensorError
Source§impl Debug for SensorError
impl Debug for SensorError
Source§impl Display for SensorError
impl Display for SensorError
impl Eq for SensorError
Source§impl Error for SensorError
impl Error for SensorError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for SensorError
impl PartialEq for SensorError
Source§fn eq(&self, other: &SensorError) -> bool
fn eq(&self, other: &SensorError) -> bool
self and other values to be equal, and is used by ==.