fixed broken temperature report. read buffer was too long; converted to long string and compared incorrectly.
sophuwu sophie@sophuwu.site
Wed, 18 Oct 2023 05:37:51 +0200
1 files changed,
3 insertions(+),
4 deletions(-)
jump to
M
main.cpp
→
main.cpp
@@ -79,16 +79,15 @@ file = fopen(ct.usepath(i).c_str(), "r");
if (file == NULL) return -1; fread(&buf, 1, ct.comp.length(), file); fclose(file); - if ( std::string(buf) == ct.comp ) { - return i; - } + if (std::string(buf).substr(0, ct.comp.length()) == ct.comp) break; } + return i; } int cpuinfo::gettemp() { FILE* file; char buf[2]; - cpufile ct = {"/sys/class/thermal/thermal_zone", "/temp", "x86_pkg_temp"}; + cpufile ct = {"/sys/class/thermal/thermal_zone", "/type", "x86_pkg_temp"}; int fileNo = findcpu(ct); if (fileNo == -1) { ct = {"/sys/class/hwmon/hwmon", "/name", "k10temp"};