From f462f640f8bc78f44c04da54cc73e74598a45985 Mon Sep 17 00:00:00 2001 From: dragonpilot Date: Wed, 13 Nov 2019 11:35:10 +1000 Subject: [PATCH] only check hw type once in thermald automatically --- common/params.py | 1 + selfdrive/dragonpilot/dragonconf/__init__.py | 1 + selfdrive/thermald.py | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/params.py b/common/params.py index 15e3eb0da..f054b1c6f 100755 --- a/common/params.py +++ b/common/params.py @@ -148,6 +148,7 @@ keys = { "DragonEnableLeadCarMovingAlert": [TxType.PERSISTENT], "DragonToyotaSnGMod": [TxType.PERSISTENT], "DragonIsEON": [TxType.PERSISTENT], + "DragonHWChecked": [TxType.PERSISTENT], } diff --git a/selfdrive/dragonpilot/dragonconf/__init__.py b/selfdrive/dragonpilot/dragonconf/__init__.py index 67383f762..9e0325102 100644 --- a/selfdrive/dragonpilot/dragonconf/__init__.py +++ b/selfdrive/dragonpilot/dragonconf/__init__.py @@ -55,6 +55,7 @@ default_conf = { 'DragonEnableLeadCarMovingAlert': '0', 'DragonToyotaSnGMod': '0', 'DragonIsEON': '1', + 'DragonHWChecked': '0', } deprecated_conf = { diff --git a/selfdrive/thermald.py b/selfdrive/thermald.py index a9d693862..004276565 100755 --- a/selfdrive/thermald.py +++ b/selfdrive/thermald.py @@ -6,7 +6,7 @@ import datetime from smbus2 import SMBus from cereal import log from common.basedir import BASEDIR -from common.params import Params +from common.params import Params, put_nonblocking from common.realtime import sec_since_boot, DT_TRML from common.numpy_fast import clip, interp from common.filter_simple import FirstOrderFilter @@ -166,6 +166,7 @@ def thermald_thread(): dragon_charging_max = int(params.get('DragonCharging')) dragon_discharging_min = int(params.get('DragonDisCharging')) charging_disabled = False + dragon_hw_checked = True if params.get('DragonHWChecked', encoding='utf8') == "1" else False dragon_is_eon = False if params.get('DragonIsEON', encoding='utf8') == "0" else True while 1: @@ -218,7 +219,17 @@ def thermald_thread(): max_comp_temp = max(max_cpu_temp, msg.thermal.mem / 10., msg.thermal.gpu / 10.) bat_temp = msg.thermal.bat/1000. - if not dragon_is_eon and (health is not None and health.health.hwType == log.HealthData.HwType.uno): + if not dragon_hw_checked: + put_nonblocking("DragonHWChecked", '1') + dragon_hw_checked = True + if health is not None and health.health.hwType == log.HealthData.HwType.uno: + dragon_is_eon = False + put_nonblocking("DragonIsEON", '0') + else: + dragon_is_eon = True + put_nonblocking("DragonIsEON", '1') + + if not dragon_is_eon: fan_speed = handle_fan_uno(max_cpu_temp, bat_temp, fan_speed) else: fan_speed = handle_fan_eon(max_cpu_temp, bat_temp, fan_speed)