add CLEAR_ON_IGNITION param type (#20810)
parent
c405442820
commit
b4447993c1
|
@ -12,6 +12,7 @@ cdef extern from "selfdrive/common/params.h":
|
|||
PERSISTENT
|
||||
CLEAR_ON_MANAGER_START
|
||||
CLEAR_ON_PANDA_DISCONNECT
|
||||
CLEAR_ON_IGNITION
|
||||
ALL
|
||||
|
||||
cdef cppclass Params:
|
||||
|
|
|
@ -13,6 +13,7 @@ cdef class ParamKeyType:
|
|||
PERSISTENT = c_ParamKeyType.PERSISTENT
|
||||
CLEAR_ON_MANAGER_START = c_ParamKeyType.CLEAR_ON_MANAGER_START
|
||||
CLEAR_ON_PANDA_DISCONNECT = c_ParamKeyType.CLEAR_ON_PANDA_DISCONNECT
|
||||
CLEAR_ON_IGNITION = c_ParamKeyType.CLEAR_ON_IGNITION
|
||||
ALL = c_ParamKeyType.ALL
|
||||
|
||||
def ensure_bytes(v):
|
||||
|
@ -43,12 +44,6 @@ cdef class Params:
|
|||
|
||||
self.p.clearAll(tx_type)
|
||||
|
||||
def manager_start(self):
|
||||
self.clear_all(ParamKeyType.CLEAR_ON_MANAGER_START)
|
||||
|
||||
def panda_disconnect(self):
|
||||
self.clear_all(ParamKeyType.CLEAR_ON_PANDA_DISCONNECT)
|
||||
|
||||
def check_key(self, key):
|
||||
key = ensure_bytes(key)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import shutil
|
|||
import stat
|
||||
import unittest
|
||||
|
||||
from common.params import Params, UnknownKeyName, put_nonblocking
|
||||
from common.params import Params, ParamKeyType, UnknownKeyName, put_nonblocking
|
||||
|
||||
class TestParams(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -35,7 +35,7 @@ class TestParams(unittest.TestCase):
|
|||
self.params.put("CarParams", "test")
|
||||
self.params.put("DongleId", "cb38263377b873ee")
|
||||
assert self.params.get("CarParams") == b"test"
|
||||
self.params.panda_disconnect()
|
||||
self.params.clear_all(ParamKeyType.CLEAR_ON_PANDA_DISCONNECT)
|
||||
assert self.params.get("CarParams") is None
|
||||
assert self.params.get("DongleId") is not None
|
||||
|
||||
|
@ -43,7 +43,7 @@ class TestParams(unittest.TestCase):
|
|||
self.params.put("CarParams", "test")
|
||||
self.params.put("DongleId", "cb38263377b873ee")
|
||||
assert self.params.get("CarParams") == b"test"
|
||||
self.params.manager_start()
|
||||
self.params.clear_all(ParamKeyType.CLEAR_ON_MANAGER_START)
|
||||
assert self.params.get("CarParams") is None
|
||||
assert self.params.get("DongleId") is not None
|
||||
|
||||
|
|
|
@ -320,12 +320,7 @@ void panda_state_thread(bool spoofing_started) {
|
|||
|
||||
// clear VIN, CarParams, and set new safety on car start
|
||||
if (ignition && !ignition_last) {
|
||||
int result = params.remove("CarVin");
|
||||
assert((result == 0) || (result == ERR_NO_VALUE));
|
||||
result = params.remove("CarParams");
|
||||
assert((result == 0) || (result == ERR_NO_VALUE));
|
||||
result = params.remove("ControlsReady");
|
||||
assert((result == 0) || (result == ERR_NO_VALUE));
|
||||
params.clearAll(CLEAR_ON_IGNITION);
|
||||
|
||||
if (!safety_setter_thread_running) {
|
||||
safety_setter_thread_running = true;
|
||||
|
|
|
@ -149,11 +149,11 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||
{"AthenadPid", PERSISTENT},
|
||||
{"CalibrationParams", PERSISTENT},
|
||||
{"CarBatteryCapacity", PERSISTENT},
|
||||
{"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT},
|
||||
{"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION},
|
||||
{"CarParamsCache", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT},
|
||||
{"CarVin", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT},
|
||||
{"CarVin", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION},
|
||||
{"CommunityFeaturesToggle", PERSISTENT},
|
||||
{"ControlsReady", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT},
|
||||
{"ControlsReady", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION},
|
||||
{"EnableLteOnroad", PERSISTENT},
|
||||
{"EndToEndToggle", PERSISTENT},
|
||||
{"CompletedTrainingVersion", PERSISTENT},
|
||||
|
|
|
@ -11,7 +11,8 @@ enum ParamKeyType {
|
|||
PERSISTENT = 0x02,
|
||||
CLEAR_ON_MANAGER_START = 0x04,
|
||||
CLEAR_ON_PANDA_DISCONNECT = 0x08,
|
||||
ALL = 0x02 | 0x04 | 0x08
|
||||
CLEAR_ON_IGNITION = 0x10,
|
||||
ALL = 0x02 | 0x04 | 0x08 | 0x10
|
||||
};
|
||||
|
||||
class Params {
|
||||
|
|
|
@ -9,7 +9,7 @@ import traceback
|
|||
import cereal.messaging as messaging
|
||||
import selfdrive.crash as crash
|
||||
from common.basedir import BASEDIR
|
||||
from common.params import Params
|
||||
from common.params import Params, ParamKeyType
|
||||
from common.text_window import TextWindow
|
||||
from selfdrive.boardd.set_time import set_time
|
||||
from selfdrive.hardware import HARDWARE, PC, TICI
|
||||
|
@ -28,7 +28,7 @@ def manager_init():
|
|||
set_time(cloudlog)
|
||||
|
||||
params = Params()
|
||||
params.manager_start()
|
||||
params.clear_all(ParamKeyType.CLEAR_ON_MANAGER_START)
|
||||
|
||||
default_params = [
|
||||
("CompletedTrainingVersion", "0"),
|
||||
|
|
|
@ -351,7 +351,6 @@ def python_replay_process(cfg, lr):
|
|||
|
||||
params = Params()
|
||||
params.clear_all()
|
||||
params.manager_start()
|
||||
params.put_bool("OpenpilotEnabledToggle", True)
|
||||
params.put_bool("Passive", False)
|
||||
params.put_bool("CommunityFeaturesToggle", True)
|
||||
|
|
|
@ -12,7 +12,7 @@ import cereal.messaging as messaging
|
|||
from cereal import log
|
||||
from common.filter_simple import FirstOrderFilter
|
||||
from common.numpy_fast import clip, interp
|
||||
from common.params import Params
|
||||
from common.params import Params, ParamKeyType
|
||||
from common.realtime import DT_TRML, sec_since_boot
|
||||
from common.dict_helpers import strip_deprecated_keys
|
||||
from selfdrive.controls.lib.alertmanager import set_offroad_alert
|
||||
|
@ -222,7 +222,7 @@ def thermald_thread():
|
|||
if pandaState_prev is not None:
|
||||
if pandaState.pandaState.pandaType == log.PandaState.PandaType.unknown and \
|
||||
pandaState_prev.pandaState.pandaType != log.PandaState.PandaType.unknown:
|
||||
params.panda_disconnect()
|
||||
params.clear_all(ParamKeyType.CLEAR_ON_PANDA_DISCONNECT)
|
||||
pandaState_prev = pandaState
|
||||
|
||||
# get_network_type is an expensive call. update every 10s
|
||||
|
|
Loading…
Reference in New Issue