Minimal Rust wrapper around Windows MSR drivers (Scaphandre or WinRing0).
scaphandre(default): Uses the Scaphandre RAPL driverwinring0: Uses the WinRing0 driver
Note: Only one feature can be enabled at a time.
To use the Scaphandre driver, execute the following:
cargo add msr-driver-rsTo use WinRing0 instead of Scaphandre, execute the following:
cargo add msr-driver-rs --no-default-features --features winring0use msr_driver_rs::MsrDriver;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let driver = MsrDriver::new()?;
let msr_pkg_energy_status = 0x0000_0611;
let value = driver.read_msr(msr_pkg_energy_status, 0)?;
println!("MSR value: {value:#x}");
Ok(())
}MsrDriver::install()?;
MsrDriver::uninstall()?;- Windows only.
new()opens the device handle. It does not install the driver.install(),uninstall()andstart()require Administrator privileges.is_installed()can be used without admin rights.
A working example is included:
cargo run --example wattseal_like
It polls the energy counter, calculates the joules consumed, and average power consumption, such as what WattSeal does.
Apache-2.0.