diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index 39cb4fcfae98b0..29dc17be90937c 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -86,7 +86,6 @@ std::unordered_map keys = { {"AccessToken", CLEAR_ON_MANAGER_START | DONT_LOG}, {"AthenadPid", PERSISTENT}, {"AthenadUploadQueue", PERSISTENT}, - {"BootedOnroad", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, {"CalibrationParams", PERSISTENT}, {"CarBatteryCapacity", PERSISTENT}, {"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON}, @@ -121,6 +120,7 @@ std::unordered_map keys = { {"IMEI", PERSISTENT}, {"InstallDate", PERSISTENT}, {"IsDriverViewEnabled", CLEAR_ON_MANAGER_START}, + {"IsEngaged", PERSISTENT}, {"IsLdwEnabled", PERSISTENT}, {"IsMetric", PERSISTENT}, {"IsOffroad", CLEAR_ON_MANAGER_START}, diff --git a/selfdrive/hardware/tici/hardware.py b/selfdrive/hardware/tici/hardware.py index 855eee908efc62..31bfa736c031f7 100644 --- a/selfdrive/hardware/tici/hardware.py +++ b/selfdrive/hardware/tici/hardware.py @@ -320,6 +320,9 @@ def get_gpu_usage_percent(self): def initialize_hardware(self): self.amplifier.initialize_configuration() + # Allow thermald to write engagement status to kmsg + os.system("sudo chmod a+w /dev/kmsg") + def get_networks(self): r = {} diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index 4ddf37f4188194..11783eebd54aa3 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -158,7 +158,7 @@ def thermald_thread() -> NoReturn: pandaState_timeout = int(1000 * 2.5 * DT_TRML) # 2.5x the expected pandaState frequency pandaState_sock = messaging.sub_sock('pandaStates', timeout=pandaState_timeout) - sm = messaging.SubMaster(["peripheralState", "gpsLocationExternal", "managerState"]) + sm = messaging.SubMaster(["peripheralState", "gpsLocationExternal", "managerState", "controlsState"]) fan_speed = 0 count = 0 @@ -191,6 +191,7 @@ def thermald_thread() -> NoReturn: handle_fan = None is_uno = False ui_running_prev = False + engaged_prev = False params = Params() power_monitor = PowerMonitoring() @@ -202,10 +203,6 @@ def thermald_thread() -> NoReturn: # TODO: use PI controller for UNO controller = PIController(k_p=0, k_i=2e-3, neg_limit=-80, pos_limit=0, rate=(1 / DT_TRML)) - # Leave flag for loggerd to indicate device was left onroad - if params.get_bool("IsOnroad"): - params.put_bool("BootedOnroad", True) - while True: pandaStates = messaging.recv_sock(pandaState_sock, wait=True) @@ -354,8 +351,23 @@ def thermald_thread() -> NoReturn: if should_start != should_start_prev or (count == 0): params.put_bool("IsOnroad", should_start) params.put_bool("IsOffroad", not should_start) + + params.put_bool("IsEngaged", False) + engaged_prev = False HARDWARE.set_power_save(not should_start) + if sm.updated['controlsState']: + engaged = sm['controlsState'].enabled + if engaged != engaged_prev: + params.put_bool("IsEngaged", engaged) + engaged_prev = engaged + + try: + with open('/dev/kmsg', 'w') as kmsg: + kmsg.write(f"[thermald] engaged: {engaged}") + except Exception: + pass + if should_start: off_ts = None if started_ts is None: