A safe rust library to communicate with the sysfs interface of lm-sensors.
Just add this to your Cargo.toml
file:
[dependencies]
libmedium = "0.2"
writable
: Standard feature that enables all functions that write to sysfs. This includes setting pwm values or disabling sensors.measurements_units
: Sensor values are returned in types from the measurements
crate.unrestricted_parsing
: This feature allows parsing of paths other than '/sys/class/hwmon'. This should only be useful for testing and debugging.```rust use libmedium::{ Hwmon, Hwmons, sensors::{Sensor, SensorBase}, };
let hwmons = Hwmons::parsereadonly().unwrap(); for (hwmonindex, hwmonname, hwmon) in &hwmons { println!("hwmon{} with name {}:", hwmonindex, hwmonname); for (, tempsensor) in hwmon.temps() { let temperature = tempsensor.readinput().unwrap(); println!("\t{}: {}", temp_sensor.name(), temperature); } } ```
writable
feature to not be disabled):```rust use libmedium::{ Hwmon, Hwmons, sensors::PwmSensor, units::{Pwm, PwmEnable}, };
let hwmons = Hwmons::parsereadwrite().unwrap(); for (, _, hwmon) in &hwmons { for (, pwm) in hwmon.pwms() { pwm.writeenable(PwmEnable::ManualControl).unwrap(); pwm.writepwm(Pwm::from_percent(100.0)).unwrap(); } } ```
This project is licensed under the MIT License - see the LICENSE.md file for details