Fix tici powerdown and add support for forcing (#20132)

* also shutdown on tici

* force powerdown

* bump panda

* abstract out shutdown and thermal config

* add comment on tici shutdown

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 8ad1c793d1c4fbb37d763b40750561ad3aca137e
This commit is contained in:
robbederks
2021-02-23 17:04:10 +01:00
committed by GitHub
parent c1606b60fd
commit 0f73681f8d
8 changed files with 38 additions and 21 deletions
+10
View File
@@ -1,5 +1,7 @@
from abc import abstractmethod
from collections import namedtuple
ThermalConfig = namedtuple('ThermalConfig', ['cpu', 'gpu', 'mem', 'bat', 'ambient'])
class HardwareBase:
@staticmethod
@@ -91,3 +93,11 @@ class HardwareBase:
@abstractmethod
def get_current_power_draw(self):
pass
@abstractmethod
def shutdown(self):
pass
@abstractmethod
def get_thermal_config(self):
pass
+7 -1
View File
@@ -6,7 +6,7 @@ import struct
import subprocess
from cereal import log
from selfdrive.hardware.base import HardwareBase
from selfdrive.hardware.base import HardwareBase, ThermalConfig
NetworkType = log.DeviceState.NetworkType
NetworkStrength = log.DeviceState.NetworkStrength
@@ -342,3 +342,9 @@ class Android(HardwareBase):
def get_current_power_draw(self):
# We don't have a good direct way to measure this on android
return None
def shutdown(self):
os.system('LD_LIBRARY_PATH="" svc power shutdown')
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))
+7 -1
View File
@@ -1,7 +1,7 @@
import random
from cereal import log
from selfdrive.hardware.base import HardwareBase
from selfdrive.hardware.base import HardwareBase, ThermalConfig
NetworkType = log.DeviceState.NetworkType
NetworkStrength = log.DeviceState.NetworkStrength
@@ -70,3 +70,9 @@ class Pc(HardwareBase):
def get_current_power_draw(self):
return 0
def shutdown(self):
print("SHUTDOWN!")
def get_thermal_config(self):
return ThermalConfig(cpu=((None,), 1), gpu=((None,), 1), mem=(None, 1), bat=(None, 1), ambient=(None, 1))
+8 -1
View File
@@ -3,7 +3,7 @@ import subprocess
from pathlib import Path
from cereal import log
from selfdrive.hardware.base import HardwareBase
from selfdrive.hardware.base import HardwareBase, ThermalConfig
NM = 'org.freedesktop.NetworkManager'
NM_CON_ACT = NM + '.Connection.Active'
@@ -176,3 +176,10 @@ class Tici(HardwareBase):
def get_current_power_draw(self):
return (self.read_param_file("/sys/class/hwmon/hwmon1/power1_input", int) / 1e6)
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")
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=(70, 1000))