Params path only in one place (#2344)

* fix params paths

* Qcom & qcom2

* This env variable is not used anywhere

* params path in only one place

* fix other PARAMS_PATH references

* absolute path is probably better
old-commit-hash: 3dd9448981
commatwo_master
Willem Melching 5 years ago committed by GitHub
parent 8531345bf9
commit 789d5176cb
  1. 2
      common/basedir.py
  2. 11
      common/params_pyx.pyx
  3. 12
      common/params_pyx_setup.py
  4. 5
      common/tests/test_params.py
  5. 4
      selfdrive/boardd/tests/test_boardd_loopback.py
  6. 22
      selfdrive/common/params.cc
  7. 3
      selfdrive/manager.py
  8. 2
      tools/README.md

@ -4,7 +4,5 @@ BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__
from common.hardware import PC from common.hardware import PC
if PC: if PC:
PERSIST = os.path.join(BASEDIR, "persist") PERSIST = os.path.join(BASEDIR, "persist")
PARAMS = os.path.join(BASEDIR, "persist", "params")
else: else:
PERSIST = "/persist" PERSIST = "/persist"
PARAMS = "/data/params"

@ -6,7 +6,8 @@ from params_pxd cimport Params as c_Params
import os import os
import threading import threading
from common.basedir import PARAMS from common.basedir import BASEDIR
os.environ['BASEDIR'] = BASEDIR
cdef enum TxType: cdef enum TxType:
PERSISTENT = 1 PERSISTENT = 1
@ -84,9 +85,9 @@ class UnknownKeyName(Exception):
cdef class Params: cdef class Params:
cdef c_Params* p cdef c_Params* p
def __cinit__(self, d=PARAMS, bool persistent_params=False): def __cinit__(self, d=None, bool persistent_params=False):
if persistent_params: if d is None:
self.p = new c_Params(True) self.p = new c_Params(persistent_params)
else: else:
self.p = new c_Params(<string>d.encode()) self.p = new c_Params(<string>d.encode())
@ -150,7 +151,7 @@ cdef class Params:
self.p.delete_db_value(key) self.p.delete_db_value(key)
def put_nonblocking(key, val, d=PARAMS): def put_nonblocking(key, val, d=None):
def f(key, val): def f(key, val):
params = Params(d) params = Params(d)
params.put(key, val) params.put(key, val)

@ -1,12 +1,24 @@
import os import os
import subprocess
from distutils.core import Extension, setup from distutils.core import Extension, setup
from Cython.Build import cythonize from Cython.Build import cythonize
from common.cython_hacks import BuildExtWithoutPlatformSuffix from common.cython_hacks import BuildExtWithoutPlatformSuffix
from common.basedir import BASEDIR from common.basedir import BASEDIR
from common.hardware import TICI
ARCH = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() # pylint: disable=unexpected-keyword-arg
sourcefiles = ['params_pyx.pyx'] sourcefiles = ['params_pyx.pyx']
extra_compile_args = ["-std=c++11"] extra_compile_args = ["-std=c++11"]
if ARCH == "aarch64":
if TICI:
extra_compile_args += ["-DQCOM2"]
else:
extra_compile_args += ["-DQCOM"]
setup(name='common', setup(name='common',
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix}, cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
ext_modules=cythonize( ext_modules=cythonize(

@ -21,6 +21,11 @@ class TestParams(unittest.TestCase):
self.params.put("DongleId", "cb38263377b873ee") self.params.put("DongleId", "cb38263377b873ee")
assert self.params.get("DongleId") == b"cb38263377b873ee" assert self.params.get("DongleId") == b"cb38263377b873ee"
def test_persist_params_put_and_get(self):
p = Params(persistent_params=True)
p.put("DongleId", "cb38263377b873ee")
assert p.get("DongleId") == b"cb38263377b873ee"
def test_params_non_ascii(self): def test_params_non_ascii(self):
st = b"\xe1\x90\xff" st = b"\xe1\x90\xff"
self.params.put("CarParams", st) self.params.put("CarParams", st)

@ -7,7 +7,7 @@ from functools import wraps
import cereal.messaging as messaging import cereal.messaging as messaging
from cereal import car from cereal import car
from common.basedir import PARAMS from common.basedir import BASEDIR
from common.hardware import ANDROID from common.hardware import ANDROID
from common.params import Params from common.params import Params
from common.spinner import Spinner from common.spinner import Spinner
@ -30,7 +30,7 @@ def reset_panda(fn):
os.environ['STARTED'] = '1' os.environ['STARTED'] = '1'
os.environ['BOARDD_LOOPBACK'] = '1' os.environ['BOARDD_LOOPBACK'] = '1'
os.environ['PARAMS_PATH'] = PARAMS os.environ['BASEDIR'] = BASEDIR
@reset_panda @reset_panda
@with_processes(['boardd']) @with_processes(['boardd'])

@ -21,23 +21,27 @@
#include "common/utilpp.h" #include "common/utilpp.h"
namespace { std::string getenv_default(const char* env_var, const char * suffix, const char* default_val) {
std::string getenv_default(const char* env_var, const char* default_val) {
const char* env_val = getenv(env_var); const char* env_val = getenv(env_var);
return std::string(env_val != NULL ? env_val : default_val); if (env_val != NULL){
return std::string(env_val) + std::string(suffix);
} else{
return std::string(default_val);
}
} }
const std::string default_params_path = getenv_default("PARAMS_PATH", "/data/params"); #if defined(QCOM) || defined(QCOM2)
const std::string default_params_path = "/data/params";
#else
const std::string default_params_path = getenv_default("BASEDIR", "persists/params", "/data/params");
#endif
#ifdef QCOM #if defined(QCOM) || defined(QCOM2)
const std::string persistent_params_path = getenv_default("PERSISTENT_PARAMS_PATH", "/persist/comma/params"); const std::string persistent_params_path = "/persist/comma/params";
#else #else
const std::string persistent_params_path = default_params_path; const std::string persistent_params_path = default_params_path;
#endif #endif
} //namespace
volatile sig_atomic_t params_do_exit = 0; volatile sig_atomic_t params_do_exit = 0;
void params_sig_handler(int signal) { void params_sig_handler(int signal) {

@ -13,12 +13,11 @@ from typing import Dict, List
from selfdrive.swaglog import cloudlog, add_logentries_handler from selfdrive.swaglog import cloudlog, add_logentries_handler
from common.basedir import BASEDIR, PARAMS from common.basedir import BASEDIR
from common.hardware import HARDWARE, ANDROID, PC from common.hardware import HARDWARE, ANDROID, PC
WEBCAM = os.getenv("WEBCAM") is not None WEBCAM = os.getenv("WEBCAM") is not None
sys.path.append(os.path.join(BASEDIR, "pyextra")) sys.path.append(os.path.join(BASEDIR, "pyextra"))
os.environ['BASEDIR'] = BASEDIR os.environ['BASEDIR'] = BASEDIR
os.environ['PARAMS_PATH'] = PARAMS
TOTAL_SCONS_NODES = 1005 TOTAL_SCONS_NODES = 1005
prebuilt = os.path.exists(os.path.join(BASEDIR, 'prebuilt')) prebuilt = os.path.exists(os.path.join(BASEDIR, 'prebuilt'))

@ -108,7 +108,7 @@ Usage:
python carcontrols/joystickd.py python carcontrols/joystickd.py
# In another terminal: # In another terminal:
PARAMS_PATH=persist/params selfdrive/boardd/boardd BASEDIR=$(pwd) selfdrive/boardd/boardd
# In another terminal: # In another terminal:
python carcontrols/debug_controls.py python carcontrols/debug_controls.py

Loading…
Cancel
Save