chestnut: flash before going onroad (#39078)

(cherry picked from commit afcbb171f69d55fdcb0a8befa65b349f6c707860)
This commit is contained in:
Daniel Koepping
2026-10-13 11:25:55 -07:00
committed by firestar5683
parent 161aaaaf44
commit 21d280d92f
+10 -3
View File
@@ -41,9 +41,10 @@ PANDA_STATES_TIMEOUT = round(1000 / SERVICE_LIST['pandaStates'].frequency * 1.5)
ONROAD_CYCLE_TIME = 1 # seconds to wait offroad after requesting an onroad cycle
class Chestnut:
# flash offroad, modeld ignores chestnut until the product string matches
# flash before going onroad, modeld ignores chestnut until the product string matches
MAX_ATTEMPTS = 3
RETRY_INTERVAL = 20.
STARTUP_TIMEOUT = 30.
def __init__(self):
self.thread: threading.Thread | None = None
@@ -52,6 +53,10 @@ class Chestnut:
self.flashed = False
self.mismatch = False
@property
def flashing(self) -> bool:
return self.thread is not None and self.thread.is_alive() and time.monotonic() - self.last_attempt < self.STARTUP_TIMEOUT
@property
def failed(self) -> bool:
return self.mismatch and self.attempts >= self.MAX_ATTEMPTS and self.thread is not None and not self.thread.is_alive() and not self.flashed
@@ -73,7 +78,7 @@ class Chestnut:
return
if self.thread is not None and self.thread.is_alive():
return
if time.monotonic() - self.last_attempt < self.RETRY_INTERVAL:
if self.attempts > 0 and time.monotonic() - self.last_attempt < self.RETRY_INTERVAL:
return
self.attempts += 1
@@ -222,7 +227,7 @@ def hardware_thread(end_event, hw_queue) -> None:
network_strength=NetworkStrength.unknown,
network_stats={'wwanTx': -1, 'wwanRx': -1},
modem_temps=[],
usb_state=[],
usb_state=get_usb_state(),
)
all_temp_filter = FirstOrderFilter(0., TEMP_TAU, DT_HW, initialized=False)
@@ -359,6 +364,8 @@ def hardware_thread(end_event, hw_queue) -> None:
# must be at an engageable thermal band to go onroad
startup_conditions["device_temp_engageable"] = thermal_status < ThermalStatus.overheated
startup_conditions["not_flashing_chestnut"] = not chestnut.flashing
# ensure device is fully booted
startup_conditions["device_booted"] = startup_conditions.get("device_booted", False) or HARDWARE.booted()