Skip to content

Commit

Permalink
Try more than one sysctl to get CPU temperature. (#330)
Browse files Browse the repository at this point in the history
* Try more than one sysctl to get CPU temperature.

Suggested by:	walter@pelissero.de
Reference:	https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210235

* Added braces and using else ifs.
  • Loading branch information
madpilot78 authored and brndnmtthws committed Oct 7, 2016
1 parent e51301a commit 271ca6d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/freebsd.cc
Expand Up @@ -426,13 +426,16 @@ double get_acpi_temperature(int fd)
int temp;
(void)fd;

if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
fprintf(stderr,
"Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
return 0.0;
if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp) == 0) {
return KELVTOC(temp);
} else if (GETSYSCTL("dev.cpu.0.temperature", temp) == 0) {
return KELVTOC(temp);
} else if (GETSYSCTL("dev.amdtemp.0.core0.sensor0", temp) == 0) {
return KELVTOC(temp);
}
fprintf(stderr, "Cannot get temperature from sysctl\n");

return KELVTOC(temp);
return 0.0;
}

static void get_battery_stats(int *battime, int *batcapacity, int *batstate, int *ac) {
Expand Down

0 comments on commit 271ca6d

Please sign in to comment.