Skip to content

ui: kick watchdog #35460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions common/watchdog.py
Original file line number Diff line number Diff line change
@@ -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.time()

if current_time - _LAST_KICK < 1.0:
return

try:
with open(f"{WATCHDOG_FN}{os.getpid()}", 'wb') as f:
f.write(struct.pack('<Q', int(current_time * 1e9)))
f.flush()
_LAST_KICK = current_time
except OSError:
pass
4 changes: 4 additions & 0 deletions selfdrive/ui/ui.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env python3
import pyray as rl
from openpilot.common.watchdog import kick_watchdog
from openpilot.system.ui.lib.application import gui_app
from openpilot.selfdrive.ui.layouts.main import MainLayout
from openpilot.selfdrive.ui.ui_state import ui_state



def main():
gui_app.init_window("UI")
main_layout = MainLayout()
Expand All @@ -15,6 +17,8 @@ def main():

main_layout.render(rl.Rectangle(0, 0, gui_app.width, gui_app.height))

kick_watchdog()


if __name__ == "__main__":
main()
3 changes: 1 addition & 2 deletions system/manager/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
from openpilot.common.basedir import BASEDIR
from openpilot.common.params import Params
from openpilot.common.swaglog import cloudlog
from openpilot.system.hardware.hw import Paths
from openpilot.common.watchdog import WATCHDOG_FN

WATCHDOG_FN = f"{Paths.shm_path()}/wd_"
ENABLE_WATCHDOG = os.getenv("NO_WATCHDOG") is None


Expand Down
Loading