From: Joseph Coffland Date: Sun, 31 Jan 2021 07:14:55 +0000 (-0800) Subject: Fixes for demo X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=711044e160381c3ceeb68115e5473452d71a20eb;p=bbctrl-firmware Fixes for demo --- diff --git a/src/py/bbctrl/MonitorTemp.py b/src/py/bbctrl/MonitorTemp.py index 41abfbc..f2987f6 100644 --- a/src/py/bbctrl/MonitorTemp.py +++ b/src/py/bbctrl/MonitorTemp.py @@ -26,16 +26,21 @@ ################################################################################ import time +import os def read_temp(): - with open('/sys/class/thermal/thermal_zone0/temp', 'r') as f: + 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) def set_max_freq(freq): - filename = '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq' - with open(filename, 'w') as f: f.write('%d\n' % 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) class MonitorTemp(object):