From 711044e160381c3ceeb68115e5473452d71a20eb Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Sat, 30 Jan 2021 23:14:55 -0800 Subject: [PATCH] Fixes for demo --- src/py/bbctrl/MonitorTemp.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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): -- 2.27.0