mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
Removed unnecesarry detection of frequency sensor types
This commit is contained in:
@@ -9,5 +9,4 @@ edition = "2018"
|
||||
[dependencies]
|
||||
bincode = "1.3"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
vulkano = "0.19"
|
||||
glob = "0.3"
|
||||
vulkano = "0.19"
|
||||
@@ -1,33 +1,17 @@
|
||||
use glob::glob;
|
||||
use std::{collections::HashMap, fs, path::PathBuf};
|
||||
use std:: {fs, path::PathBuf};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||
pub struct HWMon {
|
||||
hwmon_path: PathBuf,
|
||||
freqs: HashMap<String, u8>,
|
||||
}
|
||||
|
||||
impl HWMon {
|
||||
pub fn new(hwmon_path: &PathBuf) -> HWMon {
|
||||
let mut freqs: HashMap<String, u8> = HashMap::new();
|
||||
for entry in glob(&format!("{}/freq*_label", hwmon_path.to_str().unwrap())).expect("Couldnt read glob pattern")
|
||||
{
|
||||
let entry = entry.unwrap();
|
||||
let filename = entry.file_name().unwrap().to_str().unwrap();
|
||||
let index = filename.chars().nth(4).unwrap().to_digit(10).unwrap() as u8;
|
||||
let label = fs::read_to_string(hwmon_path.join(&format!("freq{}_label", index)))
|
||||
.unwrap()
|
||||
.trim()
|
||||
.to_string();
|
||||
freqs.insert(label, index);
|
||||
}
|
||||
println!("{:?}", freqs);
|
||||
|
||||
HWMon {
|
||||
hwmon_path: hwmon_path.clone(),
|
||||
freqs,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,13 +23,13 @@ impl HWMon {
|
||||
}
|
||||
|
||||
pub fn get_mem_freq(&self) -> i32 {
|
||||
let filename = self.hwmon_path.join(format!("freq{}_input", self.freqs.get("mclk").unwrap()));
|
||||
let filename = self.hwmon_path.join("freq2_input");
|
||||
|
||||
fs::read_to_string(filename).unwrap().trim().parse::<i32>().unwrap() / 1000 / 1000
|
||||
}
|
||||
|
||||
pub fn get_gpu_freq(&self) -> i32 {
|
||||
let filename = self.hwmon_path.join(format!("freq{}_input", self.freqs.get("sclk").unwrap()));
|
||||
let filename = self.hwmon_path.join("freq1_input");
|
||||
|
||||
fs::read_to_string(filename).unwrap().trim().parse::<i32>().unwrap() / 1000 / 1000
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user