Expand description
Contains the functionality for reading from DS18B20 sensor Manages temperature reading from DS18B20 1-Wire digital thermometers.
This module provides the Ds18b20 struct, which is designed to run as a dedicated
thread. It interfaces with the Linux 1-Wire subsystem via sysfs to periodically
read temperature data from one or more configured sensors.
§Responsibilities
- Configuration Validation: The
new()constructor performs rigorous checks on the provided configuration, ensuring that all necessary paths are specified and that sensor IDs are unique and valid before the thread starts. - Periodic Measurement: The
execute()loop periodically reads sensor data based on themeasurement_pause_duration_millissetting in the configuration. - Robust Reading: It implements a retry mechanism with a configurable pause to handle transient CRC errors or other temporary read failures common on the 1-Wire bus.
- State Sharing: It updates shared
Arc<Mutex<Ds18b20Result>>containers with the latest water and ambient temperature readings, making the data available to other parts of the application in a thread-safe manner. - Graceful Shutdown: The
execute()loop is responsive to aQuitcommand received from the main signal handler, allowing the thread to terminate cleanly. - Performance Monitoring: It includes logic to detect and log warnings if access to the shared mutexes is blocked for longer than a predefined threshold.
Modules§
Structs§
- Ds18b20
- Represents a Ds18b20 sensor module responsible for reading temperature signals.
- Ds18b20
Result Data