Files
StarPilot/openpilot/starpilot/system/jetlink/lifecycle.py
T
Zeph Leggett ca183df497 Jetlink API 3 adapter
StarPilotAdapter subclasses jetlink's Stock: StarPilot's param names, the
AOL engagement rule, the model root and a CatalogModelState history reset
that keeps its JIT buffers. jetlinkd runs jetlink's owner as it is, modeld
calls the hooks, and Galaxy and analytics read jetlink's runtime record in
place of JetlinkRuntime.

- no big-model slot or catalog keys: jetlink provisions its default model
- jetlink restores the owner's tuning itself; the port draw stays cut with
  a host plugged in
- the Jetson is asked to power off on DoShutdown only, capped at 30 s
2026-10-18 16:18:37 -05:00

27 lines
1.1 KiB
Python

"""Manager's opt-in Jetlink owner and bounded remote power-off handoff."""
from __future__ import annotations
import time
# jetlink's SHUTDOWN_TIMEOUT (25 s) plus 5 s, written out so it holds without jetlink: a jetlink regression
# must never keep a comma from powering off and drain the car's battery
SHUTDOWN_CAP_S = 30.
def enabled(params) -> bool:
# with the link off, should_run() binds nothing: jetlink's light hooks module alone loads
from openpilot.starpilot.models.jetlink_adapter import hooks
return hooks().should_run(False, params, None)
def shutdown(params, *, clock=time.monotonic, sleep=time.sleep) -> None:
# A power-off only: the Jetson is on an always-on supply and wakes only on a USB edge, so one powered off at
# a comma reboot would not come back. The resident owner must still be alive to run it.
from openpilot.starpilot.models.jetlink_adapter import hooks, link_on
if not params.get_bool('DoShutdown') or not link_on():
return
link = hooks()
deadline = clock() + SHUTDOWN_CAP_S
while not link.shutdown_step(True, 'DoShutdown') and clock() < deadline:
sleep(0.1)