From: Joseph Coffland Date: Thu, 15 Apr 2021 08:32:23 +0000 (-0700) Subject: Don't fail on temp read/write X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=39f76448897c0788f074586dc3ace8fcd0070d67;p=bbctrl-firmware Don't fail on temp read/write --- diff --git a/src/py/bbctrl/MonitorTemp.py b/src/py/bbctrl/MonitorTemp.py index 21b9746..6766d37 100644 --- a/src/py/bbctrl/MonitorTemp.py +++ b/src/py/bbctrl/MonitorTemp.py @@ -33,14 +33,19 @@ def read_temp(): path = '/sys/class/thermal/thermal_zone0/temp' if not os.path.exists(path): return 0 - with open(path, 'r') as f: - return round(int(f.read()) / 1000) + try: + with open(path, 'r') as f: + return round(int(f.read()) / 1000) + except: + return 0 def set_max_freq(freq): path = '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq' if not os.path.exists(path): return - with open(path, 'w') as f: f.write('%d\n' % freq) + try: + with open(path, 'w') as f: f.write('%d\n' % freq) + except: pass class MonitorTemp(object):