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 usinglog::info!
Implementations§
Source§impl DhtLogger
impl DhtLogger
Sourcepub fn new(
port: Box<dyn SerialPort>,
logger_config: HashMap<String, Value>,
) -> DhtLogger
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 theDhtLoggerConfig
documentation.
Sourcepub fn from_config(config: &DhtLoggerConfig) -> DhtLogger
pub fn from_config(config: &DhtLoggerConfig) -> DhtLogger
Create a DHT logger from a DhtLoggerConfig.
Sourcepub fn read_sensor(&self) -> Result<DhtSensors>
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.
Sourcepub fn wait_for_sensor(&self, retries: u32) -> Result<DhtSensors>
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.
Sourcepub fn log_measurement(&self, measurement: DhtSensors) -> Result<()>
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.
Sourcepub fn read_sensor_and_log_data(&self, retries: u32)
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.