Skip to content

Commit

Permalink
V1.19.02
Browse files Browse the repository at this point in the history
  • Loading branch information
jgyates committed Mar 25, 2024
1 parent e87461c commit 6f59b85
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
- New add on program genmqttin.py. See wiki and add on page for details
- Update to serialconfig.py to support file location changes with config.txt and cmdline.txt in latest Raspberry Pi firmware versions
- Minor update to genmonmaint.sh to use Ubunut serial device names if Non Raspberry pi OS detected
- Minor update for better error handling when getting CPU temp

## V1.19.01 -2023-12-06
- Update to genmonmaint.sh to ask about serial connection type on install (thanks @skipfire)
Expand Down
2 changes: 1 addition & 1 deletion genmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ def GetStartInfo(self, NoTile=False):

StartInfo["python"] = str(platform.python_version())

Platform = MyPlatform(log=self.log, usemetric=True)
Platform = MyPlatform(log=self.log, usemetric=True, debug = self.debug)
StartInfo["os_bits"] = Platform.PlatformBitDepth()

except Exception as e1:
Expand Down
5 changes: 4 additions & 1 deletion genmonlib/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ def __init__(

try:
if not self.bDisablePlatformStats:
self.Platform = MyPlatform(self.log, self.UseMetric)
self.Platform = MyPlatform(log=self.log, usemetric=self.UseMetric, debug = self.debug)
if self.Platform.GetRaspberryPiTemp(ReturnFloat=True) == 0.0:
self.bUseRaspberryPiCpuTempGauge = False
# CPU temp is not supported on this platform
else:
self.Platform = None
except Exception as e1:
Expand Down
18 changes: 11 additions & 7 deletions genmonlib/myplatform.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
class MyPlatform(MyCommon):

# ------------ MyPlatform::init----------------------------------------------
def __init__(self, log=None, usemetric=True):
def __init__(self, log=None, usemetric=True, debug=None):
self.log = log
self.UseMetric = usemetric
self.debug = debug

# ------------ MyPlatform::GetInfo-------------------------------------------
def GetInfo(self, JSONNum=False):
Expand Down Expand Up @@ -150,7 +151,7 @@ def GetRaspberryPiTemp(self, ReturnFloat=False, JSONNum=False):
DefaultReturn = 0.0
else:
DefaultReturn = "0"

if not self.IsOSLinux():
return DefaultReturn
try:
Expand All @@ -175,12 +176,15 @@ def GetRaspberryPiTemp(self, ReturnFloat=False, JSONNum=False):
if tempfilepath == None:
tempfilepath = "/sys/class/thermal/thermal_zone0/temp"

process = Popen(["cat", tempfilepath], stdout=PIPE)
output, _error = process.communicate()
output = output.decode("utf-8")

TempCelciusFloat = float(float(output) / 1000)
if os.path.exists(tempfilepath):
process = Popen(["cat", tempfilepath], stdout=PIPE)
output, _error = process.communicate()
output = output.decode("utf-8")

TempCelciusFloat = float(float(output) / 1000)
else:
# not sure what OS this is, possibly docker image
return DefaultReturn
if self.UseMetric:
if not ReturnFloat:
return "%.2f C" % TempCelciusFloat
Expand Down

0 comments on commit 6f59b85

Please sign in to comment.