From ed231778982a2f8087c3eb378a6dec0fdbc09266 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Fri, 14 Jan 2022 14:13:18 +0100 Subject: [PATCH] thermald: remove panda disconnect logic (#23526) * thermald: remove panda disconnect logic * keep that --- common/params_pyx.pyx | 1 - common/tests/test_params.py | 8 -------- selfdrive/common/params.cc | 10 +++++----- selfdrive/common/params.h | 7 +++---- selfdrive/thermald/thermald.py | 21 ++------------------- 5 files changed, 10 insertions(+), 37 deletions(-) diff --git a/common/params_pyx.pyx b/common/params_pyx.pyx index 7b35e815dfd973..a8c43c2f2f86eb 100755 --- a/common/params_pyx.pyx +++ b/common/params_pyx.pyx @@ -8,7 +8,6 @@ cdef extern from "selfdrive/common/params.h": cpdef enum ParamKeyType: PERSISTENT CLEAR_ON_MANAGER_START - CLEAR_ON_PANDA_DISCONNECT CLEAR_ON_IGNITION_ON CLEAR_ON_IGNITION_OFF ALL diff --git a/common/tests/test_params.py b/common/tests/test_params.py index 0b3d8dbda06260..906198871bfa5e 100644 --- a/common/tests/test_params.py +++ b/common/tests/test_params.py @@ -24,14 +24,6 @@ def test_params_non_ascii(self): self.params.put("CarParams", st) assert self.params.get("CarParams") == st - def test_params_get_cleared_panda_disconnect(self): - self.params.put("CarParams", "test") - self.params.put("DongleId", "cb38263377b873ee") - assert self.params.get("CarParams") == b"test" - self.params.clear_all(ParamKeyType.CLEAR_ON_PANDA_DISCONNECT) - assert self.params.get("CarParams") is None - assert self.params.get("DongleId") is not None - def test_params_get_cleared_manager_start(self): self.params.put("CarParams", "test") self.params.put("DongleId", "cb38263377b873ee") diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index 524e5f2b422749..9c649c94eecbe8 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -88,12 +88,12 @@ std::unordered_map keys = { {"AthenadUploadQueue", PERSISTENT}, {"CalibrationParams", PERSISTENT}, {"CarBatteryCapacity", PERSISTENT}, - {"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON}, - {"CarParamsCache", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, - {"CarVin", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON}, + {"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, + {"CarParamsCache", CLEAR_ON_MANAGER_START}, + {"CarVin", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, {"CommunityFeaturesToggle", PERSISTENT}, {"CompletedTrainingVersion", PERSISTENT}, - {"ControlsReady", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON}, + {"ControlsReady", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, {"CurrentRoute", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, {"DisablePowerDown", PERSISTENT}, {"DisableRadar_Allow", PERSISTENT}, @@ -163,7 +163,7 @@ std::unordered_map keys = { {"ApiCache_NavDestinations", PERSISTENT}, {"ApiCache_Owner", PERSISTENT}, {"Offroad_CarUnrecognized", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, - {"Offroad_ChargeDisabled", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, + {"Offroad_ChargeDisabled", CLEAR_ON_MANAGER_START }, {"Offroad_ConnectivityNeeded", CLEAR_ON_MANAGER_START}, {"Offroad_ConnectivityNeededPrompt", CLEAR_ON_MANAGER_START}, {"Offroad_InvalidTime", CLEAR_ON_MANAGER_START}, diff --git a/selfdrive/common/params.h b/selfdrive/common/params.h index c4bdde0012f1a8..be09c63d54094e 100644 --- a/selfdrive/common/params.h +++ b/selfdrive/common/params.h @@ -6,10 +6,9 @@ enum ParamKeyType { PERSISTENT = 0x02, CLEAR_ON_MANAGER_START = 0x04, - CLEAR_ON_PANDA_DISCONNECT = 0x08, - CLEAR_ON_IGNITION_ON = 0x10, - CLEAR_ON_IGNITION_OFF = 0x20, - DONT_LOG = 0x40, + CLEAR_ON_IGNITION_ON = 0x08, + CLEAR_ON_IGNITION_OFF = 0x10, + DONT_LOG = 0x20, ALL = 0xFFFFFFFF }; diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index c13d22f0e535d7..dcf7bd8f69bffc 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -13,7 +13,7 @@ from cereal import log from common.filter_simple import FirstOrderFilter from common.numpy_fast import interp -from common.params import Params, ParamKeyType +from common.params import Params from common.realtime import DT_TRML, sec_since_boot from common.dict_helpers import strip_deprecated_keys from selfdrive.controls.lib.alertmanager import set_offroad_alert @@ -185,7 +185,6 @@ def thermald_thread() -> NoReturn: current_filter = FirstOrderFilter(0., CURRENT_TAU, DT_TRML) temp_filter = FirstOrderFilter(0., TEMP_TAU, DT_TRML) - pandaState_prev = None should_start_prev = False in_car = False handle_fan = None @@ -194,7 +193,6 @@ def thermald_thread() -> NoReturn: params = Params() power_monitor = PowerMonitoring() - no_panda_cnt = 0 HARDWARE.initialize_hardware() thermal_config = HARDWARE.get_thermal_config() @@ -213,15 +211,7 @@ def thermald_thread() -> NoReturn: if pandaStates is not None and len(pandaStates.pandaStates) > 0: pandaState = pandaStates.pandaStates[0] - # If we lose connection to the panda, wait 5 seconds before going offroad - if pandaState.pandaType == log.PandaState.PandaType.unknown: - no_panda_cnt += 1 - if no_panda_cnt > DISCONNECT_TIMEOUT / DT_TRML: - if onroad_conditions["ignition"]: - cloudlog.error("Lost panda connection while onroad") - onroad_conditions["ignition"] = False - else: - no_panda_cnt = 0 + if pandaState.pandaType != log.PandaState.PandaType.unknown: onroad_conditions["ignition"] = pandaState.ignitionLine or pandaState.ignitionCan in_car = pandaState.harnessStatus != log.PandaState.HarnessStatus.notConnected @@ -242,13 +232,6 @@ def thermald_thread() -> NoReturn: setup_eon_fan() handle_fan = handle_fan_eon - # Handle disconnect - if pandaState_prev is not None: - if pandaState.pandaType == log.PandaState.PandaType.unknown and \ - pandaState_prev.pandaType != log.PandaState.PandaType.unknown: - params.clear_all(ParamKeyType.CLEAR_ON_PANDA_DISCONNECT) - pandaState_prev = pandaState - # these are expensive calls. update every 10s if (count % int(10. / DT_TRML)) == 0: try: