From cd94018426032638f0a755eb2d869b90daef6d88 Mon Sep 17 00:00:00 2001 From: Drath Date: Sat, 13 Dec 2025 21:19:48 +0100 Subject: [PATCH] make sys sensor reading more robust --- src/sys.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/sys.cpp b/src/sys.cpp index 157464e..124ea89 100644 --- a/src/sys.cpp +++ b/src/sys.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -51,10 +52,18 @@ void sys::getNetwork(Network* net, const std::string& device) { } void sys::detectHwmon(sysSensors* s, const std::string& platform) { - s->hwmon = getFirstDir("/sys/devices/platform/" + platform + "/hwmon"); + // we dont really need getFirstDir since its a static folder, but its useful for try/catch + try { + s->hwmon = getFirstDir("/sys/devices/platform/" + platform + "/hwmon"); + } catch (...) { + log(LOG::ERR, "sys::detectHwmon", "Can't open sys hwmon. Module loaded? Kernel params added?"); + return; + } } void sys::updateSensors(sysSensors* s) { + if(s->hwmon.length() < 1) + return; static char buf[8]; fastReadNum(s->hwmon + "/fan2_input", s->fan_speed[0]); fastReadNum(s->hwmon + "/fan7_input", s->fan_speed[1]);