A safe rust library to communicate with the sysfs interface of lm-sensors.
Just add this to your Cargo.toml
file:
toml
[dependencies]
libmedium = "0.5"
writeable
: Standard feature that enables all functions that write to sysfs. This includes setting pwm values and disabling sensors.uom_units
: Sensor values are returned as types from the uom
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::{ parse_hwmons, sensors::{Input, Sensor}, };
let hwmons = parsehwmons().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{}: {}", tempsensor.name(), temperature); } } ```
writeable
feature to not be disabled):```rust use libmedium::{ parse_hwmons, sensors::WriteablePwmSensor, units::{Pwm, PwmEnable}, };
let hwmons = parsehwmons().unwrap(); for (, , hwmon) in &hwmons { for (, pwm) in hwmon.writeablepwms() { pwm.writeenable(PwmEnable::ManualControl).unwrap(); pwm.writepwm(Pwm::frompercent(100.0)).unwrap(); } } ```
This project is licensed under the MIT License - see the LICENSE file for details