From cd8d07dddd2f40c1ce2a108db0b9f5d9e1042f8a Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Wed, 19 Jun 2024 21:38:39 +0200 Subject: [PATCH] Add Sunnylink registration check and process The commit introduces a new function, sunnylink_need_register, to check if the Sunnylink feature is registered. It also updates the process list to always include the manage_sunnylinkd process and introduces a new process for Sunnylink registration if it's enabled but not registered. --- system/manager/process_config.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/system/manager/process_config.py b/system/manager/process_config.py index 85fed770a0..5e709eae52 100644 --- a/system/manager/process_config.py +++ b/system/manager/process_config.py @@ -54,6 +54,11 @@ def use_sunnylink(started, params, CP: car.CarParams) -> bool: is_registered = params.get("SunnylinkDongleId", encoding='utf-8') not in (None, UNREGISTERED_SUNNYLINK_DONGLE_ID) return is_sunnylink_enabled and is_registered +def sunnylink_need_register(started, params, CP: car.CarParams) -> bool: + is_sunnylink_enabled = params.get_bool("SunnylinkEnabled") + is_registered = params.get("SunnylinkDongleId", encoding='utf-8') not in (None, UNREGISTERED_SUNNYLINK_DONGLE_ID) + return is_sunnylink_enabled and not is_registered + procs = [ DaemonProcess("manage_athenad", "system.athena.manage_athenad", "AthenadPid"), @@ -109,12 +114,12 @@ procs = [ NativeProcess("bridge", "cereal/messaging", ["./bridge"], notcar), PythonProcess("webrtcd", "system.webrtc.webrtcd", notcar), PythonProcess("webjoystick", "tools.bodyteleop.web", notcar), + + # Sunnylink <3 + DaemonProcess("manage_sunnylinkd", "system.athena.manage_sunnylinkd", "SunnylinkdPid"), + PythonProcess("sunnylink_registration", "system.manager.sunnylink", sunnylink_need_register), ] -if os.path.exists("../athena/manage_sunnylinkd.py"): - procs += [ - DaemonProcess("manage_sunnylinkd", "system.athena.manage_sunnylinkd", "SunnylinkdPid"), - ] if os.path.exists("../loggerd/sunnylink_uploader.py"): procs += [ PythonProcess("sunnylink_uploader", "system.loggerd.sunnylink_uploader", use_sunnylink),