Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix no temperature on Raspberry Pi #328

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/linux/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ impl ComponentExt for Component {
}

pub fn get_components() -> Vec<Component> {
let mut components = Vec::with_capacity(10);
if let Ok(dir) = read_dir(&Path::new("/sys/class/hwmon/")) {
let mut components = Vec::with_capacity(10);

for entry in dir {
if let Ok(entry) = entry {
let entry = entry.path();
Expand All @@ -200,15 +199,18 @@ pub fn get_components() -> Vec<Component> {
}
}
components.sort_by(|c1, c2| c1.label.to_lowercase().cmp(&c2.label.to_lowercase()));
components
} else if is_file("/sys/class/thermal/thermal_zone0/temp") {
}
if is_file("/sys/class/thermal/thermal_zone0/temp") {
// Specfic to raspberry pi.
vec![Component::new(
components.push(Component::new(
"CPU".to_owned(),
Path::new("/sys/class/thermal/thermal_zone0/temp"),
None,
None,
)]
));
}
if components.len() != 0 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this check isn't useful anymore: you can just return components.

components
} else {
Vec::new()
}
Expand Down