mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 23:33:58 +08:00
manager: initialize onroad params before starting processes (#28198)
* initialize to off on startup * params * better * better * move to helpers * rm
This commit is contained in:
@@ -36,3 +36,8 @@ def unblock_stdout() -> None:
|
||||
# whose low byte is the signal number and whose high byte is the exit status
|
||||
exit_status = os.wait()[1] >> 8
|
||||
os._exit(exit_status)
|
||||
|
||||
|
||||
def write_onroad_params(started, params):
|
||||
params.put_bool("IsOnroad", started)
|
||||
params.put_bool("IsOffroad", not started)
|
||||
|
||||
@@ -14,7 +14,7 @@ from common.params import Params, ParamKeyType
|
||||
from common.text_window import TextWindow
|
||||
from selfdrive.boardd.set_time import set_time
|
||||
from system.hardware import HARDWARE, PC
|
||||
from selfdrive.manager.helpers import unblock_stdout
|
||||
from selfdrive.manager.helpers import unblock_stdout, write_onroad_params
|
||||
from selfdrive.manager.process import ensure_running
|
||||
from selfdrive.manager.process_config import managed_processes
|
||||
from selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID
|
||||
@@ -136,6 +136,7 @@ def manager_thread() -> None:
|
||||
sm = messaging.SubMaster(['deviceState', 'carParams'], poll=['deviceState'])
|
||||
pm = messaging.PubMaster(['managerState'])
|
||||
|
||||
write_onroad_params(False, params)
|
||||
ensure_running(managed_processes.values(), False, params=params, CP=sm['carParams'], not_run=ignore)
|
||||
|
||||
started_prev = False
|
||||
@@ -150,10 +151,9 @@ def manager_thread() -> None:
|
||||
elif not started and started_prev:
|
||||
params.clear_all(ParamKeyType.CLEAR_ON_OFFROAD_TRANSITION)
|
||||
|
||||
# initialize and update onroad params, which drives boardd's safety setter thread
|
||||
if started != started_prev or sm.frame == 0:
|
||||
params.put_bool("IsOnroad", started)
|
||||
params.put_bool("IsOffroad", not started)
|
||||
# update onroad params, which drives boardd's safety setter thread
|
||||
if started != started_prev:
|
||||
write_onroad_params(started, params)
|
||||
|
||||
started_prev = started
|
||||
|
||||
|
||||
Reference in New Issue
Block a user