sophuwu.site > sysgraph
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
commit

28a2f346779ad2bc8fb3d8b24976a0adf187c9b1

parent

a23609551576c8ce70eea359ec1574949ff9321f

1 files changed, 3 insertions(+), 4 deletions(-)

jump to
M main.cppmain.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"};