Log SOM power draw (#24975)

* log SOM power draw

* bump cereal

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Willem Melching <willem.melching@gmail.com>
old-commit-hash: 684d4b75a1
taco
Robbe Derks 3 years ago committed by GitHub
parent ae596241d1
commit a6efa2c7d3
  1. 2
      cereal
  2. 13
      selfdrive/thermald/thermald.py
  3. 4
      system/hardware/base.py
  4. 3
      system/hardware/pc/hardware.py
  5. 3
      system/hardware/tici/hardware.py

@ -1 +1 @@
Subproject commit c6acc0698a604e715e960250359b6bf97e4987e3
Subproject commit 3fef4f7861e04193fdb11dbd5b0eaf6d2b102ee1

@ -348,12 +348,13 @@ def thermald_thread(end_event, hw_queue):
power_monitor.calculate(peripheralState, onroad_conditions["ignition"])
msg.deviceState.offroadPowerUsageUwh = power_monitor.get_power_used()
msg.deviceState.carBatteryCapacityUwh = max(0, power_monitor.get_car_battery_capacity())
current_power_draw = HARDWARE.get_current_power_draw() # pylint: disable=assignment-from-none
if current_power_draw is not None:
statlog.sample("power_draw", current_power_draw)
msg.deviceState.powerDrawW = current_power_draw
else:
msg.deviceState.powerDrawW = 0
current_power_draw = HARDWARE.get_current_power_draw()
statlog.sample("power_draw", current_power_draw)
msg.deviceState.powerDrawW = current_power_draw
som_power_draw = HARDWARE.get_som_power_draw()
statlog.sample("som_power_draw", som_power_draw)
msg.deviceState.somPowerDrawW = som_power_draw
# Check if we need to disable charging (handled by boardd)
msg.deviceState.chargingDisabled = power_monitor.should_disable_charging(onroad_conditions["ignition"], in_car, off_ts)

@ -86,6 +86,10 @@ class HardwareBase(ABC):
def get_current_power_draw(self):
pass
@abstractmethod
def get_som_power_draw(self):
pass
@abstractmethod
def shutdown(self):
pass

@ -55,6 +55,9 @@ class Pc(HardwareBase):
def get_current_power_draw(self):
return 0
def get_som_power_draw(self):
return 0
def shutdown(self):
print("SHUTDOWN!")

@ -362,6 +362,9 @@ class Tici(HardwareBase):
def get_current_power_draw(self):
return (self.read_param_file("/sys/class/hwmon/hwmon1/power1_input", int) / 1e6)
def get_som_power_draw(self):
return (self.read_param_file("/sys/class/power_supply/bms/voltage_now", int) * self.read_param_file("/sys/class/power_supply/bms/current_now", int) / 1e12)
def shutdown(self):
# Note that for this to work and have the device stay powered off, the panda needs to be in UsbPowerMode::CLIENT!
os.system("sudo poweroff")

Loading…
Cancel
Save