From f78ba72a85c4509d4c14b80e96c00804ee7a0844 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Tue, 3 Jun 2025 12:32:13 +0800 Subject: [PATCH] ui: add timeout check for unresponsive system detection (#35433) add time out to check if messages have stopped arriving --- selfdrive/ui/onroad/alert_renderer.py | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/selfdrive/ui/onroad/alert_renderer.py b/selfdrive/ui/onroad/alert_renderer.py index cc1b49a6a4..8efee54373 100644 --- a/selfdrive/ui/onroad/alert_renderer.py +++ b/selfdrive/ui/onroad/alert_renderer.py @@ -3,7 +3,7 @@ import pyray as rl from dataclasses import dataclass from cereal import messaging, log from openpilot.system.hardware import TICI -from openpilot.system.ui.lib.application import gui_app, FontWeight +from openpilot.system.ui.lib.application import gui_app, FontWeight, DEBUG_FPS from openpilot.system.ui.lib.label import gui_text_box from openpilot.selfdrive.ui.ui_state import ui_state @@ -70,17 +70,21 @@ class AlertRenderer: """Generate the current alert based on selfdrive state.""" ss = sm['selfdriveState'] - # Check if waiting to start - if sm.recv_frame['selfdriveState'] < ui_state.started_frame: - return ALERT_STARTUP_PENDING - - # Handle selfdrive timeout - if TICI: - ss_missing = time.monotonic() - sm.recv_time['selfdriveState'] - if ss_missing > SELFDRIVE_STATE_TIMEOUT: - if ss.enabled and (ss_missing - SELFDRIVE_STATE_TIMEOUT) < SELFDRIVE_UNRESPONSIVE_TIMEOUT: - return ALERT_CRITICAL_TIMEOUT - return ALERT_CRITICAL_REBOOT + # Check if selfdriveState messages have stopped arriving + if not sm.updated['selfdriveState']: + recv_frame = sm.recv_frame['selfdriveState'] + if (sm.frame - recv_frame) > 5 * DEBUG_FPS: + # Check if waiting to start + if recv_frame < ui_state.started_frame: + return ALERT_STARTUP_PENDING + + # Handle selfdrive timeout + if TICI: + ss_missing = time.monotonic() - sm.recv_time['selfdriveState'] + if ss_missing > SELFDRIVE_STATE_TIMEOUT: + if ss.enabled and (ss_missing - SELFDRIVE_STATE_TIMEOUT) < SELFDRIVE_UNRESPONSIVE_TIMEOUT: + return ALERT_CRITICAL_TIMEOUT + return ALERT_CRITICAL_REBOOT # No alert if size is none if ss.alertSize == 0: