From 23ea85dca656e3646354799bf59d896386c09ac0 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 6 Jun 2025 04:14:57 +0800 Subject: [PATCH] ui: kick watchdog (#35460) * kick watchdog * use global * use monotonic --- common/watchdog.py | 22 ++++++++++++++++++++++ selfdrive/ui/ui.py | 4 ++++ system/manager/process.py | 3 +-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 common/watchdog.py diff --git a/common/watchdog.py b/common/watchdog.py new file mode 100644 index 0000000000..ddb6f744e9 --- /dev/null +++ b/common/watchdog.py @@ -0,0 +1,22 @@ +import os +import time +import struct +from openpilot.system.hardware.hw import Paths + +WATCHDOG_FN = f"{Paths.shm_path()}/wd_" +_LAST_KICK = 0.0 + +def kick_watchdog(): + global _LAST_KICK + current_time = time.monotonic() + + if current_time - _LAST_KICK < 1.0: + return + + try: + with open(f"{WATCHDOG_FN}{os.getpid()}", 'wb') as f: + f.write(struct.pack('