Struct DhtLogger

Source
pub struct DhtLogger { /* private fields */ }
Expand description

DHT Logger client.

This is for reading data over serial and logging it using various means.

Supported logging methods:

  • verbose: Log incoming data using log::info!

Implementations§

Source§

impl DhtLogger

Source

pub fn new( port: Box<dyn SerialPort>, logger_config: HashMap<String, Value>, ) -> DhtLogger

Create a DHT logger from an existing serial port.

Args:

  • port: An interface to use as a serial port.
  • logger_config: Configure how data is logged. See the DhtLoggerConfig documentation.
Source

pub fn from_config(config: &DhtLoggerConfig) -> DhtLogger

Create a DHT logger from a DhtLoggerConfig.

Source

pub fn port(&self) -> Option<PathBuf>

Get the name of the serial port.

Source

pub fn read_sensor(&self) -> Result<DhtSensors>

Read sensor data over serial and return it. This blocks until data is readable over the serial interface or a timeout occurs.

Source

pub fn wait_for_sensor(&self, retries: u32) -> Result<DhtSensors>

Wait for the sensor to return data for a specified amount of retries. If the number of attempts to read data exceed the allowed number of retries, the last error message is returned. If an error occurs, this function sleeps for 100s. All sensor read errors are logged to log::trace! as they arrive.

Source

pub fn log_measurement(&self, measurement: DhtSensors) -> Result<()>

Log a measurement to the all of the logging channels configured in the logger config for the DHT Logger.

Source

pub fn read_sensor_and_log_data(&self, retries: u32)

Read data from the DHT sensor serial interface and log data to all logging channels.

Args:

  • retries: Number of sensor read retries (see `wait_for_sensor docs) before giving up.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.