diff --git a/selfdrive/manager/helpers.py b/selfdrive/manager/helpers.py index f8607fffc6..ba529910e5 100644 --- a/selfdrive/manager/helpers.py +++ b/selfdrive/manager/helpers.py @@ -3,7 +3,13 @@ import sys import fcntl import errno import signal +import shutil +import subprocess +import tempfile +import threading +from openpilot.common.basedir import BASEDIR +from openpilot.common.params import Params def unblock_stdout() -> None: # get a non-blocking stdout @@ -41,3 +47,16 @@ def unblock_stdout() -> None: def write_onroad_params(started, params): params.put_bool("IsOnroad", started) params.put_bool("IsOffroad", not started) + + +def save_bootlog(): + # copy current params + tmp = tempfile.mkdtemp() + shutil.copytree(Params().get_param_path() + "/..", tmp, dirs_exist_ok=True) + + env = os.environ.copy() + env['PARAMS_ROOT'] = tmp + + t = threading.Thread(target=subprocess.call, args=("./bootlog", ), kwargs={'cwd': os.path.join(BASEDIR, "system/loggerd"), 'env': env}) + t.daemon = True + t.start() diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index 8b9bba4a47..2bc14945fe 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -2,7 +2,6 @@ import datetime import os import signal -import subprocess import sys import traceback from typing import List, Tuple, Union @@ -10,12 +9,11 @@ from typing import List, Tuple, Union from cereal import log import cereal.messaging as messaging import openpilot.selfdrive.sentry as sentry -from openpilot.common.basedir import BASEDIR from openpilot.common.params import Params, ParamKeyType from openpilot.common.text_window import TextWindow from openpilot.selfdrive.boardd.set_time import set_time from openpilot.system.hardware import HARDWARE, PC -from openpilot.selfdrive.manager.helpers import unblock_stdout, write_onroad_params +from openpilot.selfdrive.manager.helpers import unblock_stdout, write_onroad_params, save_bootlog from openpilot.selfdrive.manager.process import ensure_running from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID @@ -31,7 +29,7 @@ def manager_init() -> None: set_time(cloudlog) # save boot log - subprocess.call("./bootlog", cwd=os.path.join(BASEDIR, "system/loggerd")) + save_bootlog() params = Params() params.clear_all(ParamKeyType.CLEAR_ON_MANAGER_START) diff --git a/system/hardware/hw.h b/system/hardware/hw.h index 2f6ccfffda..013a885a81 100644 --- a/system/hardware/hw.h +++ b/system/hardware/hw.h @@ -30,13 +30,13 @@ namespace Path { } inline std::string params() { - return Hardware::PC() ? util::getenv("PARAMS_ROOT", Path::comma_home() + "/params") : "/data/params"; + return util::getenv("PARAMS_ROOT", Hardware::PC ? (Path::comma_home() + "/params") : "/data/params"); } inline std::string rsa_file() { return Hardware::PC() ? Path::comma_home() + "/persist/comma/id_rsa" : "/persist/comma/id_rsa"; } - + inline std::string swaglog_ipc() { return "ipc:///tmp/logmessage" + Path::openpilot_prefix(); }