Cool down device before going onroad if CPU temp over 75 C (#1688)

* Block going onroad when temperatures are too high

* add relay check
old-commit-hash: 955d2aefdd
This commit is contained in:
Willem Melching 2020-06-12 15:03:32 -07:00 committed by GitHub
parent c25d71dd31
commit 4d4c3f021b
1 changed files with 6 additions and 2 deletions

View File

@ -184,6 +184,7 @@ def thermald_thread():
should_start_prev = False
handle_fan = None
is_uno = False
has_relay = False
params = Params()
pm = PowerMonitoring()
@ -212,6 +213,7 @@ def thermald_thread():
# Setup fan handler on first connect to panda
if handle_fan is None and health.health.hwType != log.HealthData.HwType.unknown:
is_uno = health.health.hwType == log.HealthData.HwType.uno
has_relay = health.health.hwType in [log.HealthData.HwType.blackPanda, log.HealthData.HwType.uno]
if is_uno or not ANDROID:
cloudlog.info("Setting up UNO fan handler")
@ -268,8 +270,10 @@ def thermald_thread():
fan_speed = handle_fan(max_cpu_temp, bat_temp, fan_speed, ignition)
msg.thermal.fanSpeed = fan_speed
# thermal logic with hysterisis
if max_cpu_temp > 107. or bat_temp >= 63.:
# If device is offroad we want to cool down before going onroad
# since going onroad increases load and can make temps go over 107
# We only do this if there is a relay that prevents the car from faulting
if max_cpu_temp > 107. or bat_temp >= 63. or (has_relay and (started_ts is None) and max_cpu_temp > 75.0):
# onroad not allowed
thermal_status = ThermalStatus.danger
elif max_comp_temp > 100.0 or bat_temp > 60.: