pub struct Thermometer { /* private fields */ }Expand description
A DS18B20 the kernel exposes as a w1_slave file.
§Examples
use pamoja_core::Sensor;
use pamoja_sensors::ds18b20::linux::Thermometer;
let mut probe = Thermometer::new("000005e2fdc3");
let scratchpad = probe.read().await?;
println!("{:.4} C", scratchpad.temperature_celsius());Implementations§
Source§impl Thermometer
impl Thermometer
Sourcepub fn new(serial: &str) -> Thermometer
pub fn new(serial: &str) -> Thermometer
Sourcepub fn at(path: impl Into<PathBuf>) -> Thermometer
pub fn at(path: impl Into<PathBuf>) -> Thermometer
Sourcepub fn serial(&self) -> Option<&str>
pub fn serial(&self) -> Option<&str>
Returns the serial the kernel named the thermometer’s directory after.
§Returns
The twelve hex digits after 28-, as in 000005e2fdc3, which tell one probe
from another and stay with the part for life. None when the file does not sit
in a DS18B20’s directory, as a thermometer named by at may
not.
§Examples
use pamoja_sensors::ds18b20::linux::Thermometer;
assert_eq!(Thermometer::new("000005e2fdc3").serial(), Some("000005e2fdc3"));
assert_eq!(Thermometer::at("/tmp/w1_slave").serial(), None);Sourcepub fn discover() -> Result<Vec<Thermometer>>
pub fn discover() -> Result<Vec<Thermometer>>
Sourcepub fn discover_in(devices: &Path) -> Result<Vec<Thermometer>>
pub fn discover_in(devices: &Path) -> Result<Vec<Thermometer>>
Sourcepub fn read_scratchpad(&self) -> Result<Scratchpad, ThermometerError>
pub fn read_scratchpad(&self) -> Result<Scratchpad, ThermometerError>
Reads the file, which makes the kernel run a conversion, and decodes it.
§Returns
The CRC-checked scratchpad.
§Errors
Returns ThermometerError::Io if the file cannot be read and
ThermometerError::Sensor if it does not decode.
Trait Implementations§
Source§impl Clone for Thermometer
impl Clone for Thermometer
Source§fn clone(&self) -> Thermometer
fn clone(&self) -> Thermometer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Thermometer
impl Debug for Thermometer
impl Eq for Thermometer
Source§impl PartialEq for Thermometer
impl PartialEq for Thermometer
Source§impl Sensor for Thermometer
impl Sensor for Thermometer
Source§type Reading = Scratchpad
type Reading = Scratchpad
The value produced by a single read, for example a temperature or a fix.
Source§async fn read(&mut self) -> Result<Scratchpad>
async fn read(&mut self) -> Result<Scratchpad>
Takes a single reading from the sensor. Read more
impl StructuralPartialEq for Thermometer
Auto Trait Implementations§
impl Freeze for Thermometer
impl RefUnwindSafe for Thermometer
impl Send for Thermometer
impl Sync for Thermometer
impl Unpin for Thermometer
impl UnsafeUnpin for Thermometer
impl UnwindSafe for Thermometer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more