mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-06-25 12:02:05 +08:00
1bd2a2f007
add back the dirinvg model even if dupped. it's not responisibility of this mr Refactor Sunnylink's operation and default state handling This update refines the operation and handling of the Sunnylink feature, focusing on its management within the launch script and the logic for its default state. Starting with the default state, the 'SunnylinkEnabled' parameter is no longer hard-coded to 0. Instead, it now depends on the presence of a release_channel or release_sp_channel. Furthermore, Sunnylink is set to be active in all non-release builds by default. Regarding the launch script, obsolete invocations of Sunnylink are avoided. This procedure actively checks for Sunnylink registration status before initiating the related processes, effectively conserving system resources. Also, this modifies the launching order of the mapd installer and manager. As for the functionality of Sunnylink, crucial improvements are brought into effect: - The status display post Sunnylink registration is made more accurate and informative, with the inclusion of a progress color. - The handling of Sunnylink capability is overhauled, ensuring that if Sunnylink feature is disabled, a clear warning is logged and the daemon process shuts down correctly. - System exit conditions now accommodate the Sunnylink registration status to ensure clean termination. - The start of Sunnylink Uploader is now strictly dependent on the validation of Sunnylink registration. - This optimization is also incorporated into the 'manage_athenad' method which now gracefully handles any potential null values for Sunnylink Dongle ID. This comprehensive update aims to enhance the transparency, functionality, and efficient operation of the Sunnylink feature.
136 lines
6.6 KiB
Python
136 lines
6.6 KiB
Python
import os
|
|
|
|
from cereal import car
|
|
from openpilot.common.api.sunnylink import UNREGISTERED_SUNNYLINK_DONGLE_ID
|
|
from openpilot.common.params import Params
|
|
from openpilot.system.hardware import PC, TICI
|
|
from openpilot.selfdrive.sunnypilot import get_model_generation
|
|
from openpilot.system.manager.process import PythonProcess, NativeProcess, DaemonProcess
|
|
from openpilot.system.mapd_manager import MAPD_PATH, COMMON_DIR
|
|
|
|
WEBCAM = os.getenv("USE_WEBCAM") is not None
|
|
|
|
def driverview(started: bool, params: Params, CP: car.CarParams) -> bool:
|
|
return started or params.get_bool("IsDriverViewEnabled")
|
|
|
|
def notcar(started: bool, params: Params, CP: car.CarParams) -> bool:
|
|
return started and CP.notCar
|
|
|
|
def iscar(started: bool, params: Params, CP: car.CarParams) -> bool:
|
|
return started and not CP.notCar
|
|
|
|
def logging(started, params, CP: car.CarParams) -> bool:
|
|
run = (not CP.notCar) or not params.get_bool("DisableLogging")
|
|
return started and run
|
|
|
|
def ublox_available() -> bool:
|
|
return os.path.exists('/dev/ttyHS0') and not os.path.exists('/persist/comma/use-quectel-gps')
|
|
|
|
def ublox(started, params, CP: car.CarParams) -> bool:
|
|
use_ublox = ublox_available()
|
|
if use_ublox != params.get_bool("UbloxAvailable"):
|
|
params.put_bool("UbloxAvailable", use_ublox)
|
|
return started and use_ublox
|
|
|
|
def qcomgps(started, params, CP: car.CarParams) -> bool:
|
|
return started and not ublox_available()
|
|
|
|
def always_run(started, params, CP: car.CarParams) -> bool:
|
|
return True
|
|
|
|
def only_onroad(started: bool, params, CP: car.CarParams) -> bool:
|
|
return started
|
|
|
|
def only_offroad(started, params, CP: car.CarParams) -> bool:
|
|
return not started
|
|
|
|
def model_use_nav(started, params, CP: car.CarParams) -> bool:
|
|
custom_model, model_gen = get_model_generation(params)
|
|
return started and custom_model and model_gen not in (0, 4)
|
|
|
|
|
|
def use_sunnylink(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 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"),
|
|
|
|
NativeProcess("camerad", "system/camerad", ["./camerad"], driverview),
|
|
NativeProcess("logcatd", "system/logcatd", ["./logcatd"], only_onroad),
|
|
NativeProcess("proclogd", "system/proclogd", ["./proclogd"], only_onroad),
|
|
PythonProcess("logmessaged", "system.logmessaged", always_run),
|
|
PythonProcess("micd", "system.micd", iscar),
|
|
PythonProcess("timed", "system.timed", always_run, enabled=not PC),
|
|
|
|
PythonProcess("dmonitoringmodeld", "selfdrive.modeld.dmonitoringmodeld", driverview, enabled=(not PC or WEBCAM)),
|
|
NativeProcess("encoderd", "system/loggerd", ["./encoderd"], only_onroad),
|
|
NativeProcess("stream_encoderd", "system/loggerd", ["./encoderd", "--stream"], notcar),
|
|
NativeProcess("loggerd", "system/loggerd", ["./loggerd"], logging),
|
|
NativeProcess("modeld", "selfdrive/modeld", ["./modeld"], only_onroad),
|
|
NativeProcess("mapsd", "selfdrive/navd", ["./mapsd"], model_use_nav),
|
|
PythonProcess("navmodeld", "selfdrive.modeld.navmodeld", model_use_nav),
|
|
NativeProcess("sensord", "system/sensord", ["./sensord"], only_onroad, enabled=not PC),
|
|
NativeProcess("ui", "selfdrive/ui", ["./ui"], always_run, watchdog_max_dt=(5 if not PC else None)),
|
|
PythonProcess("soundd", "selfdrive.ui.soundd", only_onroad),
|
|
NativeProcess("locationd", "selfdrive/locationd", ["./locationd"], only_onroad),
|
|
NativeProcess("pandad", "selfdrive/pandad", ["./pandad"], always_run, enabled=False),
|
|
PythonProcess("calibrationd", "selfdrive.locationd.calibrationd", only_onroad),
|
|
PythonProcess("torqued", "selfdrive.locationd.torqued", only_onroad),
|
|
PythonProcess("controlsd", "selfdrive.controls.controlsd", only_onroad),
|
|
PythonProcess("card", "selfdrive.car.card", only_onroad),
|
|
PythonProcess("deleter", "system.loggerd.deleter", always_run),
|
|
PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", driverview, enabled=(not PC or WEBCAM)),
|
|
PythonProcess("qcomgpsd", "system.qcomgpsd.qcomgpsd", qcomgps, enabled=TICI),
|
|
#PythonProcess("ugpsd", "system.ugpsd", only_onroad, enabled=TICI),
|
|
PythonProcess("navd", "selfdrive.navd.navd", only_onroad),
|
|
PythonProcess("pandad", "selfdrive.pandad.pandad", always_run),
|
|
PythonProcess("paramsd", "selfdrive.locationd.paramsd", only_onroad),
|
|
NativeProcess("ubloxd", "system/ubloxd", ["./ubloxd"], ublox, enabled=TICI),
|
|
PythonProcess("pigeond", "system.ubloxd.pigeond", ublox, enabled=TICI),
|
|
PythonProcess("plannerd", "selfdrive.controls.plannerd", only_onroad),
|
|
PythonProcess("radard", "selfdrive.controls.radard", only_onroad),
|
|
PythonProcess("hardwared", "system.hardware.hardwared", always_run),
|
|
PythonProcess("tombstoned", "system.tombstoned", always_run, enabled=not PC),
|
|
PythonProcess("updated", "system.updated.updated", only_offroad, enabled=not PC),
|
|
PythonProcess("uploader", "system.loggerd.uploader", always_run),
|
|
PythonProcess("statsd", "system.statsd", always_run),
|
|
|
|
# PFEIFER - MAPD {{
|
|
NativeProcess("mapd", COMMON_DIR, [MAPD_PATH], always_run, enabled=not PC),
|
|
PythonProcess("mapd_manager", "system.mapd_manager", always_run, enabled=not PC),
|
|
# }} PFEIFER - MAPD
|
|
|
|
PythonProcess("otisserv", "selfdrive.navd.otisserv", always_run),
|
|
PythonProcess("fleet_manager", "system.fleetmanager.fleet_manager", always_run, enabled=not PC),
|
|
|
|
# debug 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("../loggerd/sunnylink_uploader.py"):
|
|
procs += [
|
|
PythonProcess("sunnylink_uploader", "system.loggerd.sunnylink_uploader", use_sunnylink),
|
|
]
|
|
|
|
if os.path.exists("./gitlab_runner.sh") and not PC:
|
|
# Only devs!
|
|
procs += [
|
|
NativeProcess("gitlab_runner_start", "system/manager", ["./gitlab_runner.sh", "start"], only_offroad, sigkill=False),
|
|
NativeProcess("gitlab_runner_stop", "system/manager", ["./gitlab_runner.sh", "stop"], only_onroad, sigkill=False)
|
|
]
|
|
|
|
managed_processes = {p.name: p for p in procs}
|