only run get_nvme_temps on C3 (#22464)

* only run get_nvme_temps on C3

* temperatures

* fix imports

Co-authored-by: Comma Device <device@comma.ai>
pull/22466/head
Adeeb Shihadeh 2021-10-06 20:32:22 -07:00 committed by GitHub
parent e424f7182c
commit 493e32431c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 15 deletions

View File

@ -1,5 +1,3 @@
import json
import subprocess
from abc import abstractmethod
from collections import namedtuple
@ -20,17 +18,6 @@ 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
@ -139,6 +126,10 @@ class HardwareBase:
def get_modem_temperatures(self):
pass
@abstractmethod
def get_nvme_temperatures(self):
pass
@abstractmethod
def initialize_hardware(self):
pass

View File

@ -393,6 +393,9 @@ class Android(HardwareBase):
# Not sure if we can get this on the LeEco
return []
def get_nvme_temperatures(self):
return []
def initialize_hardware(self):
pass

View File

@ -95,6 +95,9 @@ class Pc(HardwareBase):
def get_modem_temperatures(self):
return []
def get_nvme_temperatures(self):
return []
def initialize_hardware(self):
pass

View File

@ -1,7 +1,8 @@
import json
import os
import subprocess
from functools import cached_property
from enum import IntEnum
import subprocess
from pathlib import Path
from cereal import log
@ -232,6 +233,16 @@ class Tici(HardwareBase):
except Exception:
return []
def get_nvme_temperatures(self):
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
# We don't have a battery, so let's use some sane constants
def get_battery_capacity(self):
return 100

View File

@ -255,7 +255,7 @@ def thermald_thread():
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()
nvme_temps = HARDWARE.get_nvme_temperatures()
modem_temps = HARDWARE.get_modem_temperatures()
# Log modem version once