log nvme temp (#22296)

* log nvme temp

* fix high cpu

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 212d2c3998852d4eb374e54479f79078b10c2762
This commit is contained in:
Adeeb Shihadeh
2021-09-21 14:39:07 -07:00
committed by GitHub
parent c1bab646a5
commit f53a09f40e
2 changed files with 18 additions and 1 deletions
+13
View File
@@ -1,3 +1,5 @@
import json
import subprocess
from abc import abstractmethod
from collections import namedtuple
@@ -18,6 +20,17 @@ class HardwareBase:
except Exception:
return default
@staticmethod
def get_nvme_temps():
ret = []
try:
out = subprocess.check_output("sudo smartctl -aj /dev/nvme0", shell=True)
dat = json.loads(out)
ret = list(map(int, dat["nvme_smart_health_information_log"]["temperature_sensors"]))
except Exception:
pass
return ret
@abstractmethod
def reboot(self, reason=None):
pass
+5 -1
View File
@@ -178,6 +178,7 @@ def thermald_thread():
network_info = None
modem_version = None
registered_count = 0
nvme_temps = None
current_filter = FirstOrderFilter(0., CURRENT_TAU, DT_TRML)
temp_filter = FirstOrderFilter(0., TEMP_TAU, DT_TRML)
@@ -258,12 +259,13 @@ def thermald_thread():
params.clear_all(ParamKeyType.CLEAR_ON_PANDA_DISCONNECT)
pandaState_prev = pandaState
# get_network_type is an expensive call. update every 10s
# these are expensive calls. update every 10s
if (count % int(10. / DT_TRML)) == 0:
try:
network_type = HARDWARE.get_network_type()
network_strength = HARDWARE.get_network_strength(network_type)
network_info = HARDWARE.get_network_info() # pylint: disable=assignment-from-none
nvme_temps = HARDWARE.get_nvme_temps()
# Log modem version once
if modem_version is None:
@@ -292,6 +294,8 @@ def thermald_thread():
msg.deviceState.networkStrength = network_strength
if network_info is not None:
msg.deviceState.networkInfo = network_info
if nvme_temps is not None:
msg.deviceState.nvmeTempC = nvme_temps
msg.deviceState.batteryPercent = HARDWARE.get_battery_capacity()
msg.deviceState.batteryCurrent = HARDWARE.get_battery_current()