log nvme temp (#22296)

* log nvme temp

* fix high cpu

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 212d2c3998
commatwo_master
Adeeb Shihadeh 4 years ago committed by GitHub
parent c1bab646a5
commit f53a09f40e
  1. 13
      selfdrive/hardware/base.py
  2. 6
      selfdrive/thermald/thermald.py

@ -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

@ -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()

Loading…
Cancel
Save