Skip to content

Commit

Permalink
Wait 5s before going offroad after panda disconnect (#1406)
Browse files Browse the repository at this point in the history
* wait 10s before going offroad after panda disconnect

* Add cloudlog

* Typo

* 5 s
  • Loading branch information
pd0wm committed Apr 20, 2020
1 parent 6bbf020 commit 96686d1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion selfdrive/thermald/thermald.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
CPU_TEMP_TAU = 5. # 5s time constant
DAYS_NO_CONNECTIVITY_MAX = 7 # do not allow to engage after a week without internet
DAYS_NO_CONNECTIVITY_PROMPT = 4 # send an offroad prompt after 4 days with no internet
DISCONNECT_TIMEOUT = 5. # wait 5 seconds before going offroad after disconnect so you get an alert

LEON = False
last_eon_fan_val = None
Expand Down Expand Up @@ -185,6 +186,7 @@ def thermald_thread():

params = Params()
pm = PowerMonitoring()
no_panda_cnt = 0

while 1:
health = messaging.recv_sock(health_sock, wait=True)
Expand All @@ -194,7 +196,17 @@ def thermald_thread():

if health is not None:
usb_power = health.health.usbPowerMode != log.HealthData.UsbPowerMode.client
ignition = health.health.ignitionLine or health.health.ignitionCan

# If we lose connection to the panda, wait 5 seconds before going offroad
if health.health.hwType == log.HealthData.HwType.unknown:
no_panda_cnt += 1
if no_panda_cnt > DISCONNECT_TIMEOUT / DT_TRML:
if ignition:
cloudlog.error("Lost panda connection while onroad")
ignition = False
else:
no_panda_cnt = 0
ignition = health.health.ignitionLine or health.health.ignitionCan

# Setup fan handler on first connect to panda
if handle_fan is None and health.health.hwType != log.HealthData.HwType.unknown:
Expand Down

0 comments on commit 96686d1

Please sign in to comment.