thermald: track power usage / pmic temps (#23013)

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
pull/23020/head
George Hotz 3 years ago committed by GitHub
parent 6964adec39
commit 6462ced209
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cereal
  2. 2
      selfdrive/hardware/base.py
  3. 2
      selfdrive/hardware/eon/hardware.py
  4. 2
      selfdrive/hardware/pc/hardware.py
  5. 2
      selfdrive/hardware/tici/hardware.py
  6. 3
      selfdrive/thermald/thermald.py

@ -1 +1 @@
Subproject commit 032aca6ca38a342e26fb9cc986b7f72b91cd9b55 Subproject commit 238e0c5793daed7dce6e1e072c4ae510f06ea515

@ -1,7 +1,7 @@
from abc import abstractmethod from abc import abstractmethod
from collections import namedtuple from collections import namedtuple
ThermalConfig = namedtuple('ThermalConfig', ['cpu', 'gpu', 'mem', 'bat', 'ambient']) ThermalConfig = namedtuple('ThermalConfig', ['cpu', 'gpu', 'mem', 'bat', 'ambient', 'pmic'])
class HardwareBase: class HardwareBase:
@staticmethod @staticmethod

@ -369,7 +369,7 @@ class Android(HardwareBase):
os.system('LD_LIBRARY_PATH="" svc power shutdown') os.system('LD_LIBRARY_PATH="" svc power shutdown')
def get_thermal_config(self): def get_thermal_config(self):
return ThermalConfig(cpu=((5, 7, 10, 12), 10), gpu=((16,), 10), mem=(2, 10), bat=(29, 1000), ambient=(25, 1)) return ThermalConfig(cpu=((5, 7, 10, 12), 10), gpu=((16,), 10), mem=(2, 10), bat=(29, 1000), ambient=(25, 1), pmic=((22,), 1))
def set_screen_brightness(self, percentage): def set_screen_brightness(self, percentage):
with open("/sys/class/leds/lcd-backlight/brightness", "w") as f: with open("/sys/class/leds/lcd-backlight/brightness", "w") as f:

@ -78,7 +78,7 @@ class Pc(HardwareBase):
print("SHUTDOWN!") print("SHUTDOWN!")
def get_thermal_config(self): def get_thermal_config(self):
return ThermalConfig(cpu=((None,), 1), gpu=((None,), 1), mem=(None, 1), bat=(None, 1), ambient=(None, 1)) return ThermalConfig(cpu=((None,), 1), gpu=((None,), 1), mem=(None, 1), bat=(None, 1), ambient=(None, 1), pmic=((None,), 1))
def set_screen_brightness(self, percentage): def set_screen_brightness(self, percentage):
pass pass

@ -275,7 +275,7 @@ class Tici(HardwareBase):
os.system("sudo poweroff") os.system("sudo poweroff")
def get_thermal_config(self): def get_thermal_config(self):
return ThermalConfig(cpu=((1, 2, 3, 4, 5, 6, 7, 8), 1000), gpu=((48,49), 1000), mem=(15, 1000), bat=(None, 1), ambient=(65, 1000)) return ThermalConfig(cpu=((1, 2, 3, 4, 5, 6, 7, 8), 1000), gpu=((48,49), 1000), mem=(15, 1000), bat=(None, 1), ambient=(65, 1000), pmic=((35, 36), 1000))
def set_screen_brightness(self, percentage): def set_screen_brightness(self, percentage):
try: try:

@ -66,6 +66,7 @@ def read_thermal(thermal_config):
dat.deviceState.gpuTempC = [read_tz(z) / thermal_config.gpu[1] for z in thermal_config.gpu[0]] dat.deviceState.gpuTempC = [read_tz(z) / thermal_config.gpu[1] for z in thermal_config.gpu[0]]
dat.deviceState.memoryTempC = read_tz(thermal_config.mem[0]) / thermal_config.mem[1] dat.deviceState.memoryTempC = read_tz(thermal_config.mem[0]) / thermal_config.mem[1]
dat.deviceState.ambientTempC = read_tz(thermal_config.ambient[0]) / thermal_config.ambient[1] dat.deviceState.ambientTempC = read_tz(thermal_config.ambient[0]) / thermal_config.ambient[1]
dat.deviceState.pmicTempC = [read_tz(z) / thermal_config.pmic[1] for z in thermal_config.pmic[0]]
return dat return dat
@ -406,6 +407,8 @@ def thermald_thread():
power_monitor.calculate(peripheralState, startup_conditions["ignition"]) power_monitor.calculate(peripheralState, startup_conditions["ignition"])
msg.deviceState.offroadPowerUsageUwh = power_monitor.get_power_used() msg.deviceState.offroadPowerUsageUwh = power_monitor.get_power_used()
msg.deviceState.carBatteryCapacityUwh = max(0, power_monitor.get_car_battery_capacity()) msg.deviceState.carBatteryCapacityUwh = max(0, power_monitor.get_car_battery_capacity())
current_power_draw = HARDWARE.get_current_power_draw() # pylint: disable=assignment-from-none
msg.deviceState.powerDrawW = current_power_draw if current_power_draw is not None else 0
# Check if we need to disable charging (handled by boardd) # Check if we need to disable charging (handled by boardd)
msg.deviceState.chargingDisabled = power_monitor.should_disable_charging(startup_conditions["ignition"], in_car, off_ts) msg.deviceState.chargingDisabled = power_monitor.should_disable_charging(startup_conditions["ignition"], in_car, off_ts)

Loading…
Cancel
Save