diff --git a/cereal b/cereal index 1b342ce4e0..6eb3994daa 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 1b342ce4e00cacc0c87f3339cd7696e2ab0e62fe +Subproject commit 6eb3994daa0f64f57a36606a7bdd982ed2ac9d2d diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index b5fa439671..fca5020297 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -131,16 +131,15 @@ def manager_thread() -> None: ensure_running(managed_processes.values(), started=False, not_run=ignore) started_prev = False - sm = messaging.SubMaster(['deviceState']) + sm = messaging.SubMaster(['deviceState', 'carParams'], poll=['deviceState']) pm = messaging.PubMaster(['managerState']) while True: sm.update() - not_run = ignore[:] started = sm['deviceState'].started driverview = params.get_bool("IsDriverViewEnabled") - ensure_running(managed_processes.values(), started, driverview, not_run) + ensure_running(managed_processes.values(), started=started, driverview=driverview, notcar=sm['carParams'].notCar, not_run=ignore) # trigger an update after going offroad if started_prev and not started and 'updated' in managed_processes: diff --git a/selfdrive/manager/process.py b/selfdrive/manager/process.py index 4cd9783b2b..8551e96f3c 100644 --- a/selfdrive/manager/process.py +++ b/selfdrive/manager/process.py @@ -71,6 +71,7 @@ class ManagerProcess(ABC): sigkill = False persistent = False driverview = False + notcar = False proc: Optional[Process] = None enabled = True name = "" @@ -182,13 +183,14 @@ class ManagerProcess(ABC): class NativeProcess(ManagerProcess): - def __init__(self, name, cwd, cmdline, enabled=True, persistent=False, driverview=False, unkillable=False, sigkill=False, watchdog_max_dt=None): + def __init__(self, name, cwd, cmdline, enabled=True, persistent=False, driverview=False, notcar=False, unkillable=False, sigkill=False, watchdog_max_dt=None): self.name = name self.cwd = cwd self.cmdline = cmdline self.enabled = enabled self.persistent = persistent self.driverview = driverview + self.notcar = notcar self.unkillable = unkillable self.sigkill = sigkill self.watchdog_max_dt = watchdog_max_dt @@ -213,12 +215,13 @@ class NativeProcess(ManagerProcess): class PythonProcess(ManagerProcess): - def __init__(self, name, module, enabled=True, persistent=False, driverview=False, unkillable=False, sigkill=False, watchdog_max_dt=None): + def __init__(self, name, module, enabled=True, persistent=False, driverview=False, notcar=False, unkillable=False, sigkill=False, watchdog_max_dt=None): self.name = name self.module = module self.enabled = enabled self.persistent = persistent self.driverview = driverview + self.notcar = notcar self.unkillable = unkillable self.sigkill = sigkill self.watchdog_max_dt = watchdog_max_dt @@ -284,7 +287,8 @@ class DaemonProcess(ManagerProcess): pass -def ensure_running(procs: ValuesView[ManagerProcess], started: bool, driverview: bool=False, not_run: Optional[List[str]]=None) -> None: +def ensure_running(procs: ValuesView[ManagerProcess], started: bool, driverview: bool=False, notcar: bool=False, + not_run: Optional[List[str]]=None) -> None: if not_run is None: not_run = [] @@ -297,6 +301,11 @@ def ensure_running(procs: ValuesView[ManagerProcess], started: bool, driverview: p.start() elif p.driverview and driverview: p.start() + elif p.notcar: + if notcar: + p.start() + else: + p.stop(block=False) elif started: p.start() else: diff --git a/selfdrive/manager/process_config.py b/selfdrive/manager/process_config.py index 63790058fe..43b22036dc 100644 --- a/selfdrive/manager/process_config.py +++ b/selfdrive/manager/process_config.py @@ -14,7 +14,7 @@ procs = [ NativeProcess("logcatd", "selfdrive/logcatd", ["./logcatd"]), NativeProcess("loggerd", "selfdrive/loggerd", ["./loggerd"]), NativeProcess("modeld", "selfdrive/modeld", ["./modeld"]), - NativeProcess("navd", "selfdrive/ui/navd", ["./navd"], enabled=(PC or TICI), persistent=True), + NativeProcess("navd", "selfdrive/ui/navd", ["./navd"], persistent=True), NativeProcess("proclogd", "selfdrive/proclogd", ["./proclogd"]), NativeProcess("sensord", "selfdrive/sensord", ["./sensord"], enabled=not PC), NativeProcess("ubloxd", "selfdrive/locationd", ["./ubloxd"], enabled=(not PC or WEBCAM)), @@ -38,6 +38,9 @@ procs = [ PythonProcess("uploader", "selfdrive.loggerd.uploader", persistent=True), PythonProcess("statsd", "selfdrive.statsd", persistent=True), + NativeProcess("bridge", "cereal/messaging", ["./bridge"], notcar=True), + PythonProcess("webjoystick", "tools.joystick.web", notcar=True), + # Experimental PythonProcess("rawgpsd", "selfdrive.sensord.rawgps.rawgpsd", enabled=os.path.isfile("/persist/comma/use-quectel-rawgps")), ] diff --git a/tools/joystick/web.py b/tools/joystick/web.py index 403041362e..143ca115c5 100755 --- a/tools/joystick/web.py +++ b/tools/joystick/web.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 -from flask import Flask import time import threading +from flask import Flask + import cereal.messaging as messaging app = Flask(__name__) @@ -31,7 +32,7 @@ setInterval(function(){ def hello_world(): return index -last_send_time = time.time() +last_send_time = time.monotonic() @app.route("/control//") def control(x, y): global last_send_time @@ -42,12 +43,12 @@ def control(x, y): dat.testJoystick.axes = [y,x] dat.testJoystick.buttons = [False] pm.send('testJoystick', dat) - last_send_time = time.time() + last_send_time = time.monotonic() return "" def handle_timeout(): while 1: - this_time = time.time() + this_time = time.monotonic() if (last_send_time+0.5) < this_time: print("timeout, no web in %.2f s" % (this_time-last_send_time)) dat = messaging.new_message('testJoystick') @@ -56,7 +57,9 @@ def handle_timeout(): pm.send('testJoystick', dat) time.sleep(0.1) -if __name__ == '__main__': +def main(): threading.Thread(target=handle_timeout, daemon=True).start() app.run(host="0.0.0.0") +if __name__ == '__main__': + main()