Params: rm nonblocking funcs (#38016)

* rm nonblocking funcs

* same behavior

* and put_bool

* missing!

* and nonblocking

* cmt
This commit is contained in:
Shane Smiskol
2026-05-11 20:00:00 -07:00
committed by GitHub
parent 11c14a138f
commit 3a764c0ae3
74 changed files with 255 additions and 260 deletions
+1 -1
View File
@@ -14,6 +14,6 @@ if __name__ == "__main__":
if len(sys.argv) == 3:
val = sys.argv[2]
print(f"SET: {key} = {val}")
params.put(key, val)
params.put(key, val, block=True)
elif len(sys.argv) == 2:
print(f"GET: {key} = {params.get(key)}")
+13 -18
View File
@@ -141,33 +141,28 @@ cdef class Params:
cdef ParamKeyType t = self.p.getKeyType(k)
return ensure_bytes(self.python2cpp(type(dat), t, dat, key))
def put(self, key, dat):
def put(self, key, dat, bool block = False):
"""
Warning: This function blocks until the param is written to disk!
Warning: block=True blocks until the param is written to disk!
In very rare cases this can take over a second, and your code will hang.
Use the put_nonblocking, put_bool_nonblocking in time sensitive code, but
in general try to avoid writing params as much as possible.
Use block=False in time sensitive code, but in general try to avoid
writing params as much as possible.
"""
cdef string k = self.check_key(key)
cdef string dat_bytes = self._put_cast(key, dat)
with nogil:
self.p.put(k, dat_bytes)
if block:
self.p.put(k, dat_bytes)
else:
self.p.putNonBlocking(k, dat_bytes)
def put_bool(self, key, bool val):
def put_bool(self, key, bool val, bool block = False):
cdef string k = self.check_key(key)
with nogil:
self.p.putBool(k, val)
def put_nonblocking(self, key, dat):
cdef string k = self.check_key(key)
cdef string dat_bytes = self._put_cast(key, dat)
with nogil:
self.p.putNonBlocking(k, dat_bytes)
def put_bool_nonblocking(self, key, bool val):
cdef string k = self.check_key(key)
with nogil:
self.p.putBoolNonBlocking(k, val)
if block:
self.p.putBool(k, val)
else:
self.p.putBoolNonBlocking(k, val)
def remove(self, key):
cdef string k = self.check_key(key)
+19 -19
View File
@@ -12,17 +12,17 @@ class TestParams:
self.params = Params()
def test_params_put_and_get(self):
self.params.put("DongleId", "cb38263377b873ee")
self.params.put("DongleId", "cb38263377b873ee", block=True)
assert self.params.get("DongleId") == "cb38263377b873ee"
def test_params_non_ascii(self):
st = b"\xe1\x90\xff"
self.params.put("CarParams", st)
self.params.put("CarParams", st, block=True)
assert self.params.get("CarParams") == st
def test_params_get_cleared_manager_start(self):
self.params.put("CarParams", b"test")
self.params.put("DongleId", "cb38263377b873ee")
self.params.put("CarParams", b"test", block=True)
self.params.put("DongleId", "cb38263377b873ee", block=True)
assert self.params.get("CarParams") == b"test"
undefined_param = self.params.get_param_path(uuid.uuid4().hex)
@@ -36,15 +36,15 @@ class TestParams:
assert not os.path.isfile(undefined_param)
def test_params_two_things(self):
self.params.put("DongleId", "bob")
self.params.put("AthenadPid", 123)
self.params.put("DongleId", "bob", block=True)
self.params.put("AthenadPid", 123, block=True)
assert self.params.get("DongleId") == "bob"
assert self.params.get("AthenadPid") == 123
def test_params_get_block(self):
def _delayed_writer():
time.sleep(0.1)
self.params.put("CarParams", b"test")
self.params.put("CarParams", b"test", block=True)
threading.Thread(target=_delayed_writer).start()
assert self.params.get("CarParams") is None
assert self.params.get("CarParams", block=True) == b"test"
@@ -57,10 +57,10 @@ class TestParams:
self.params.get_bool("swag")
with pytest.raises(UnknownKeyName):
self.params.put("swag", "abc")
self.params.put("swag", "abc", block=True)
with pytest.raises(UnknownKeyName):
self.params.put_bool("swag", True)
self.params.put_bool("swag", True, block=True)
def test_remove_not_there(self):
assert self.params.get("CarParams") is None
@@ -71,23 +71,23 @@ class TestParams:
self.params.remove("IsMetric")
assert not self.params.get_bool("IsMetric")
self.params.put_bool("IsMetric", True)
self.params.put_bool("IsMetric", True, block=True)
assert self.params.get_bool("IsMetric")
self.params.put_bool("IsMetric", False)
self.params.put_bool("IsMetric", False, block=True)
assert not self.params.get_bool("IsMetric")
self.params.put("IsMetric", True)
self.params.put("IsMetric", True, block=True)
assert self.params.get_bool("IsMetric")
self.params.put("IsMetric", False)
self.params.put("IsMetric", False, block=True)
assert not self.params.get_bool("IsMetric")
def test_put_non_blocking_with_get_block(self):
q = Params()
def _delayed_writer():
time.sleep(0.1)
Params().put_nonblocking("CarParams", b"test")
Params().put("CarParams", b"test")
threading.Thread(target=_delayed_writer).start()
assert q.get("CarParams") is None
assert q.get("CarParams", True) == b"test"
@@ -96,7 +96,7 @@ class TestParams:
q = Params()
def _delayed_writer():
time.sleep(0.1)
Params().put_bool_nonblocking("CarParams", True)
Params().put_bool("CarParams", True)
threading.Thread(target=_delayed_writer).start()
assert q.get("CarParams") is None
assert q.get("CarParams", True) == b"1"
@@ -123,19 +123,19 @@ class TestParams:
def test_params_get_type(self):
# json
self.params.put("ApiCache_FirehoseStats", {"a": 0})
self.params.put("ApiCache_FirehoseStats", {"a": 0}, block=True)
assert self.params.get("ApiCache_FirehoseStats") == {"a": 0}
# int
self.params.put("BootCount", 1441)
self.params.put("BootCount", 1441, block=True)
assert self.params.get("BootCount") == 1441
# bool
self.params.put("AdbEnabled", True)
self.params.put("AdbEnabled", True, block=True)
assert self.params.get("AdbEnabled")
assert isinstance(self.params.get("AdbEnabled"), bool)
# time
now = datetime.datetime.now(datetime.UTC)
self.params.put("InstallDate", now)
self.params.put("InstallDate", now, block=True)
assert self.params.get("InstallDate") == now
+8 -8
View File
@@ -33,7 +33,7 @@ def obd_callback(params: Params) -> ObdCallback:
if params.get_bool("ObdMultiplexingEnabled") != obd_multiplexing:
cloudlog.warning(f"Setting OBD multiplexing to {obd_multiplexing}")
params.remove("ObdMultiplexingChanged")
params.put_bool("ObdMultiplexingEnabled", obd_multiplexing)
params.put_bool("ObdMultiplexingEnabled", obd_multiplexing, block=True)
params.get_bool("ObdMultiplexingChanged", block=True)
cloudlog.warning("OBD multiplexing set successfully")
return set_obd_multiplexing
@@ -102,7 +102,7 @@ class Car:
self.CP = self.CI.CP
# continue onto next fingerprinting step in pandad
self.params.put_bool("FirmwareQueryDone", True)
self.params.put_bool("FirmwareQueryDone", True, block=True)
else:
self.CI, self.CP = CI, CI.CP
self.RI = RI
@@ -122,7 +122,7 @@ class Car:
with open("/cache/params/SecOCKey") as f:
user_key = f.readline().strip()
if len(user_key) == 32:
self.params.put("SecOCKey", user_key)
self.params.put("SecOCKey", user_key, block=True)
except Exception:
pass
@@ -140,13 +140,13 @@ class Car:
# Write previous route's CarParams
prev_cp = self.params.get("CarParamsPersistent")
if prev_cp is not None:
self.params.put("CarParamsPrevRoute", prev_cp)
self.params.put("CarParamsPrevRoute", prev_cp, block=True)
# Write CarParams for controls and radard
cp_bytes = self.CP.to_bytes()
self.params.put("CarParams", cp_bytes)
self.params.put_nonblocking("CarParamsCache", cp_bytes)
self.params.put_nonblocking("CarParamsPersistent", cp_bytes)
self.params.put("CarParams", cp_bytes, block=True)
self.params.put("CarParamsCache", cp_bytes)
self.params.put("CarParamsPersistent", cp_bytes)
self.v_cruise_helper = VCruiseHelper(self.CP)
@@ -228,7 +228,7 @@ class Car:
# TODO: this can make us miss at least a few cycles when doing an ECU knockout
self.CI.init(self.CP, *self.can_callbacks)
# signal pandad to switch to car safety mode
self.params.put_bool_nonblocking("ControlsReady", True)
self.params.put_bool("ControlsReady", True)
if self.sm.all_alive(['carControl']):
# send car controls over can
+2 -2
View File
@@ -26,9 +26,9 @@ if __name__ == "__main__":
# Set up params for pandad
params = Params()
params.remove("FirmwareQueryDone")
params.put_bool("IsOnroad", False)
params.put_bool("IsOnroad", False, block=True)
time.sleep(0.2) # thread is 10 Hz
params.put_bool("IsOnroad", True)
params.put_bool("IsOnroad", True, block=True)
obd_callback(params)(not args.no_obd)
+2 -2
View File
@@ -30,9 +30,9 @@ if __name__ == "__main__":
# Set up params for pandad
params = Params()
params.remove("FirmwareQueryDone")
params.put_bool("IsOnroad", False)
params.put_bool("IsOnroad", False, block=True)
time.sleep(0.2) # thread is 10 Hz
params.put_bool("IsOnroad", True)
params.put_bool("IsOnroad", True, block=True)
set_obd_multiplexing = obd_callback(params)
extra: Any = None
+1 -1
View File
@@ -19,4 +19,4 @@ if __name__ == "__main__":
cp_bytes = CP.to_bytes()
for p in ("CarParams", "CarParamsCache", "CarParamsPersistent"):
Params().put(p, cp_bytes)
Params().put(p, cp_bytes, block=True)
+1 -1
View File
@@ -8,7 +8,7 @@ from openpilot.system.hardware import HARDWARE
if __name__ == "__main__":
CP = car.CarParams(notCar=True, wheelbase=1, steerRatio=10)
Params().put("CarParams", CP.to_bytes())
Params().put("CarParams", CP.to_bytes(), block=True)
procs = ['camerad', 'ui', 'modeld', 'calibrationd', 'plannerd', 'dmonitoringmodeld', 'dmonitoringd']
for p in procs:
+1 -1
View File
@@ -167,7 +167,7 @@ class Calibrator:
write_this_cycle = (self.idx == 0) and (self.block_idx % (INPUTS_WANTED//5) == 5)
if self.param_put and write_this_cycle:
self.params.put_nonblocking("CalibrationParams", self.get_msg(True).to_bytes())
self.params.put("CalibrationParams", self.get_msg(True).to_bytes())
def handle_v_ego(self, v_ego: float) -> None:
self.v_ego = v_ego
+1 -1
View File
@@ -411,4 +411,4 @@ def main():
pm.send('liveDelay', lag_msg_dat)
if sm.frame % 1200 == 0: # cache every 60 seconds
params.put_nonblocking("LiveDelay", lag_msg_dat)
params.put("LiveDelay", lag_msg_dat)
+2 -2
View File
@@ -212,7 +212,7 @@ def migrate_cached_vehicle_params_if_needed(params: Params):
last_parameters_msg.liveParameters.steerRatio = last_parameters_data_old['steerRatio']
last_parameters_msg.liveParameters.stiffnessFactor = last_parameters_data_old['stiffnessFactor']
last_parameters_msg.liveParameters.angleOffsetAverageDeg = last_parameters_data_old['angleOffsetAverageDeg']
params.put("LiveParametersV2", last_parameters_msg.to_bytes())
params.put("LiveParametersV2", last_parameters_msg.to_bytes(), block=True)
except Exception as e:
cloudlog.error(f"Failed to perform parameter migration: {e}")
params.remove("LiveParameters")
@@ -290,7 +290,7 @@ def main():
msg_dat = msg.to_bytes()
if sm.frame % 1200 == 0: # once a minute
params.put_nonblocking("LiveParametersV2", msg_dat)
params.put("LiveParametersV2", msg_dat)
pm.send('liveParameters', msg_dat)
@@ -36,7 +36,7 @@ class TestCalibrationd:
msg.liveCalibration.validBlocks = random.randint(1, 10)
msg.liveCalibration.rpyCalib = [random.random() for _ in range(3)]
msg.liveCalibration.height = [random.random() for _ in range(1)]
Params().put("CalibrationParams", msg.to_bytes())
Params().put("CalibrationParams", msg.to_bytes(), block=True)
c = Calibrator(param_put=True)
np.testing.assert_allclose(msg.liveCalibration.rpyCalib, c.rpy)
+2 -2
View File
@@ -53,8 +53,8 @@ class TestLagd:
msg = messaging.new_message('liveDelay')
msg.liveDelay.lateralDelayEstimate = random.random()
msg.liveDelay.validBlocks = random.randint(1, 10)
params.put("LiveDelay", msg.to_bytes())
params.put("CarParamsPrevRoute", CP.as_builder().to_bytes())
params.put("LiveDelay", msg.to_bytes(), block=True)
params.put("CarParamsPrevRoute", CP.as_builder().to_bytes(), block=True)
saved_lag_params = retrieve_initial_lag(params, CP)
assert saved_lag_params is not None
+5 -5
View File
@@ -27,8 +27,8 @@ class TestParamsd:
CP = next(m for m in lr if m.which() == "carParams").carParams
msg = get_random_live_parameters(CP)
params.put("LiveParametersV2", msg.to_bytes())
params.put("CarParamsPrevRoute", CP.as_builder().to_bytes())
params.put("LiveParametersV2", msg.to_bytes(), block=True)
params.put("CarParamsPrevRoute", CP.as_builder().to_bytes(), block=True)
migrate_cached_vehicle_params_if_needed(params) # this is not tested here but should not mess anything up or throw an error
sr, sf, offset, p_init = retrieve_initial_vehicle_params(params, CP, replay=True, debug=True)
@@ -46,8 +46,8 @@ class TestParamsd:
CP = next(m for m in lr if m.which() == "carParams").carParams
msg = get_random_live_parameters(CP)
params.put("LiveParameters", msg.liveParameters.to_dict())
params.put("CarParamsPrevRoute", CP.as_builder().to_bytes())
params.put("LiveParameters", msg.liveParameters.to_dict(), block=True)
params.put("CarParamsPrevRoute", CP.as_builder().to_bytes(), block=True)
params.remove("LiveParametersV2")
migrate_cached_vehicle_params_if_needed(params)
@@ -59,7 +59,7 @@ class TestParamsd:
def test_read_saved_params_corrupted_old_format(self):
params = Params()
params.put("LiveParameters", {})
params.put("LiveParameters", {}, block=True)
params.remove("LiveParametersV2")
migrate_cached_vehicle_params_if_needed(params)
+1 -1
View File
@@ -268,7 +268,7 @@ def main(demo=False):
# Cache points every 60 seconds while onroad
if sm.frame % 240 == 0:
msg = estimator.get_msg(valid=sm.all_checks(), with_points=True)
params.put_nonblocking("LiveTorqueParameters", msg.to_bytes())
params.put("LiveTorqueParameters", msg.to_bytes())
if __name__ == "__main__":
+1 -1
View File
@@ -41,7 +41,7 @@ def dmonitoringd_thread():
if (sm['driverStateV2'].frameId % 6000 == 0 and not demo_mode and
DM.wheelpos_offsetter.filtered_stat.n > DM.settings._WHEELPOS_FILTER_MIN_COUNT and
DM.wheel_on_right == (DM.wheelpos_offsetter.filtered_stat.M > DM.settings._WHEELPOS_THRESHOLD)):
params.put_bool_nonblocking("IsRhdDetected", DM.wheel_on_right)
params.put_bool("IsRhdDetected", DM.wheel_on_right)
def main():
dmonitoringd_thread()
+1 -1
View File
@@ -70,7 +70,7 @@ def main() -> None:
with Panda(s) as p:
health = p.health()
if p.is_internal() and health["heartbeat_lost"]:
Params().put_bool("PandaHeartbeatLost", True)
Params().put_bool("PandaHeartbeatLost", True, block=True)
cloudlog.event("heartbeat lost", deviceState=health)
except Exception:
cloudlog.exception("pandad.uncaught_exception")
@@ -42,9 +42,9 @@ def setup_pandad():
safety_config.safetyModel = car.CarParams.SafetyModel.allOutput
cp.safetyConfigs = [safety_config]
params.put_bool("FirmwareQueryDone", True)
params.put_bool("ControlsReady", True)
params.put("CarParams", cp.to_bytes())
params.put_bool("FirmwareQueryDone", True, block=True)
params.put_bool("ControlsReady", True, block=True)
params.put("CarParams", cp.to_bytes(), block=True)
publish_device_state(pm, True)
with Timeout(90, "pandad didn't set safety mode"):
+1 -1
View File
@@ -17,7 +17,7 @@ def set_offroad_alert(alert: str, show_alert: bool, extra_text: str | None = Non
if show_alert:
a = copy.copy(OFFROAD_ALERTS[alert])
a['extra'] = extra_text or ''
Params().put(alert, a)
Params().put(alert, a, block=True)
else:
Params().remove(alert)
+2 -2
View File
@@ -190,7 +190,7 @@ class SelfdriveD:
if not self.CP.notCar:
# Block engaging until ignition cycle after max number or time of distractions
if self.sm['driverMonitoringState'].lockout and not self.dm_lockout_set:
self.params.put_bool_nonblocking("DriverTooDistracted", True)
self.params.put_bool("DriverTooDistracted", True)
self.dm_lockout_set = True
# No entry conditions
if self.sm['driverMonitoringState'].lockout or self.sm['driverMonitoringState'].alwaysOnLockout:
@@ -425,7 +425,7 @@ class SelfdriveD:
if self.CP.openpilotLongitudinalControl:
if any(not be.pressed and be.type == ButtonType.gapAdjustCruise for be in CS.buttonEvents):
self.personality = (self.personality - 1) % 3
self.params.put_nonblocking('LongitudinalPersonality', self.personality)
self.params.put('LongitudinalPersonality', self.personality)
self.events.add(EventName.personalityChanged)
def data_sample(self):
+4 -4
View File
@@ -18,15 +18,15 @@ def set_params_enabled():
os.environ['LOGPRINT'] = "debug"
params = Params()
params.put("HasAcceptedTerms", terms_version)
params.put("CompletedTrainingVersion", training_version)
params.put_bool("OpenpilotEnabledToggle", True)
params.put("HasAcceptedTerms", terms_version, block=True)
params.put("CompletedTrainingVersion", training_version, block=True)
params.put_bool("OpenpilotEnabledToggle", True, block=True)
# valid calib
msg = messaging.new_message('liveCalibration')
msg.liveCalibration.validBlocks = 20
msg.liveCalibration.rpyCalib = [0.0, 0.0, 0.0]
params.put("CalibrationParams", msg.to_bytes())
params.put("CalibrationParams", msg.to_bytes(), block=True)
def release_only(f):
@wraps(f)
@@ -191,9 +191,9 @@ class ProcessContainer:
params = Params()
for k, v in params_config.items():
if isinstance(v, bool):
params.put_bool(k, v)
params.put_bool(k, v, block=True)
else:
params.put(k, v)
params.put(k, v, block=True)
self.environ_config = environ_config
@@ -372,7 +372,7 @@ def get_car_params_callback(rc, pm, msgs, fingerprint):
CP = get_car(can_recv, lambda _msgs: None, lambda obd: None, params.get_bool("AlphaLongitudinalEnabled"), False, cached_params=cached_params).CP
params.put("CarParams", CP.to_bytes())
params.put("CarParams", CP.to_bytes(), block=True)
def card_rcv_callback(msg, cfg, frame):
+1 -1
View File
@@ -119,7 +119,7 @@ class TestOnroad:
# setup env
params = Params()
params.remove("CurrentRoute")
params.put_bool("RecordFront", True)
params.put_bool("RecordFront", True, block=True)
set_params_enabled()
os.environ['REPLAY'] = '1'
os.environ['MSGQ_PREALLOC'] = '1'
+1 -1
View File
@@ -92,7 +92,7 @@ class TestUpdated:
return subprocess.Popen(updated_path, env=os.environ)
def _start_updater(self, offroad=True, nosleep=False):
self.params.put_bool("IsOffroad", offroad)
self.params.put_bool("IsOffroad", offroad, block=True)
self.updated_proc = self._get_updated_proc()
if not nosleep:
time.sleep(1)
+4 -4
View File
@@ -66,7 +66,7 @@ class TrainingGuide(Widget):
if self._step == DM_RECORD_STEP:
yes = rl.check_collision_point_rec(mouse_pos, DM_RECORD_YES_RECT)
print(f"putting RecordFront to {yes}")
ui_state.params.put_bool("RecordFront", yes)
ui_state.params.put_bool("RecordFront", yes, block=True)
# Restart training?
elif self._step == len(self._image_paths) - 1:
@@ -153,7 +153,7 @@ class DeclinePage(Widget):
click_callback=self._on_uninstall_clicked)
def _on_uninstall_clicked(self):
ui_state.params.put_bool("DoUninstall", True)
ui_state.params.put_bool("DoUninstall", True, block=True)
gui_app.request_close()
def _render(self, _):
@@ -194,13 +194,13 @@ class OnboardingWindow(Widget):
self._state = OnboardingState.TERMS
def _on_terms_accepted(self):
ui_state.params.put("HasAcceptedTerms", terms_version)
ui_state.params.put("HasAcceptedTerms", terms_version, block=True)
self._state = OnboardingState.ONBOARDING
if self._training_done:
gui_app.pop_widget()
def _on_completed_training(self):
ui_state.params.put("CompletedTrainingVersion", training_version)
ui_state.params.put("CompletedTrainingVersion", training_version, block=True)
def _render(self, _):
if self._training_guide is None:
+1 -1
View File
@@ -2,4 +2,4 @@ from openpilot.selfdrive.ui.ui_state import ui_state
def restart_needed_callback(_=None):
ui_state.params.put_bool_nonblocking("OnroadCycleRequested", True)
ui_state.params.put_bool("OnroadCycleRequested", True)
+17 -17
View File
@@ -150,44 +150,44 @@ class DeveloperLayout(Widget):
item.action_item.set_state(self._params.get_bool(key))
def _on_enable_ui_debug(self, state: bool):
self._params.put_bool("ShowDebugInfo", state)
self._params.put_bool("ShowDebugInfo", state, block=True)
gui_app.set_show_touches(state)
gui_app.set_show_fps(state)
def _on_enable_adb(self, state: bool):
self._params.put_bool("AdbEnabled", state)
self._params.put_bool("AdbEnabled", state, block=True)
def _on_enable_ssh(self, state: bool):
self._params.put_bool("SshEnabled", state)
self._params.put_bool("SshEnabled", state, block=True)
def _on_joystick_debug_mode(self, state: bool):
self._params.put_bool("JoystickDebugMode", state)
self._params.put_bool("LongitudinalManeuverMode", False)
self._params.put_bool("JoystickDebugMode", state, block=True)
self._params.put_bool("LongitudinalManeuverMode", False, block=True)
self._long_maneuver_toggle.action_item.set_state(False)
self._params.put_bool("LateralManeuverMode", False)
self._params.put_bool("LateralManeuverMode", False, block=True)
self._lat_maneuver_toggle.action_item.set_state(False)
def _on_long_maneuver_mode(self, state: bool):
self._params.put_bool("LongitudinalManeuverMode", state)
self._params.put_bool("JoystickDebugMode", False)
self._params.put_bool("LongitudinalManeuverMode", state, block=True)
self._params.put_bool("JoystickDebugMode", False, block=True)
self._joystick_toggle.action_item.set_state(False)
self._params.put_bool("LateralManeuverMode", False)
self._params.put_bool("LateralManeuverMode", False, block=True)
self._lat_maneuver_toggle.action_item.set_state(False)
def _on_lat_maneuver_mode(self, state: bool):
self._params.put_bool("LateralManeuverMode", state)
self._params.put_bool("ExperimentalMode", False)
self._params.put_bool("JoystickDebugMode", False)
self._params.put_bool("LateralManeuverMode", state, block=True)
self._params.put_bool("ExperimentalMode", False, block=True)
self._params.put_bool("JoystickDebugMode", False, block=True)
self._joystick_toggle.action_item.set_state(False)
self._params.put_bool("LongitudinalManeuverMode", False)
self._params.put_bool("LongitudinalManeuverMode", False, block=True)
self._long_maneuver_toggle.action_item.set_state(False)
def _on_alpha_long_enabled(self, state: bool):
if state:
def confirm_callback(result: DialogResult):
if result == DialogResult.CONFIRM:
self._params.put_bool("AlphaLongitudinalEnabled", True)
self._params.put_bool("OnroadCycleRequested", True)
self._params.put_bool("AlphaLongitudinalEnabled", True, block=True)
self._params.put_bool("OnroadCycleRequested", True, block=True)
self._update_toggles()
else:
self._alpha_long_toggle.action_item.set_state(False)
@@ -200,6 +200,6 @@ class DeveloperLayout(Widget):
gui_app.push_widget(dlg)
else:
self._params.put_bool("AlphaLongitudinalEnabled", False)
self._params.put_bool("OnroadCycleRequested", True)
self._params.put_bool("AlphaLongitudinalEnabled", False, block=True)
self._params.put_bool("OnroadCycleRequested", True, block=True)
self._update_toggles()
+3 -3
View File
@@ -105,7 +105,7 @@ class DeviceLayout(Widget):
self._params.remove("LiveParameters")
self._params.remove("LiveParametersV2")
self._params.remove("LiveDelay")
self._params.put_bool("OnroadCycleRequested", True)
self._params.put_bool("OnroadCycleRequested", True, block=True)
self._update_calib_description()
dialog = ConfirmDialog(tr("Are you sure you want to reset calibration?"), tr("Reset"), callback=reset_calibration)
@@ -166,7 +166,7 @@ class DeviceLayout(Widget):
def perform_reboot(result: DialogResult):
if not ui_state.engaged and result == DialogResult.CONFIRM:
self._params.put_bool_nonblocking("DoReboot", True)
self._params.put_bool("DoReboot", True)
dialog = ConfirmDialog(tr("Are you sure you want to reboot?"), tr("Reboot"), callback=perform_reboot)
gui_app.push_widget(dialog)
@@ -178,7 +178,7 @@ class DeviceLayout(Widget):
def perform_power_off(result: DialogResult):
if not ui_state.engaged and result == DialogResult.CONFIRM:
self._params.put_bool_nonblocking("DoShutdown", True)
self._params.put_bool("DoShutdown", True)
dialog = ConfirmDialog(tr("Are you sure you want to power off?"), tr("Power Off"), callback=perform_power_off)
gui_app.push_widget(dialog)
+3 -3
View File
@@ -168,7 +168,7 @@ class SoftwareLayout(Widget):
def _on_uninstall(self):
def handle_uninstall_confirmation(result: DialogResult):
if result == DialogResult.CONFIRM:
ui_state.params.put_bool("DoUninstall", True)
ui_state.params.put_bool("DoUninstall", True, block=True)
dialog = ConfirmDialog(tr("Are you sure you want to uninstall?"), tr("Uninstall"), callback=handle_uninstall_confirmation)
gui_app.push_widget(dialog)
@@ -176,7 +176,7 @@ class SoftwareLayout(Widget):
def _on_install_update(self):
# Trigger reboot to install update
self._install_btn.action_item.set_enabled(False)
ui_state.params.put_bool("DoReboot", True)
ui_state.params.put_bool("DoReboot", True, block=True)
def _on_select_branch(self):
# Get available branches and order
@@ -195,7 +195,7 @@ class SoftwareLayout(Widget):
# Confirmed selection
if result == DialogResult.CONFIRM and self._branch_dialog is not None and self._branch_dialog.selection:
selection = self._branch_dialog.selection
ui_state.params.put("UpdaterTargetBranch", selection)
ui_state.params.put("UpdaterTargetBranch", selection, block=True)
self._branch_btn.action_item.set_value(selection)
os.system("pkill -SIGUSR1 -f system.updated.updated")
self._branch_dialog = None
+6 -6
View File
@@ -217,8 +217,8 @@ class TogglesLayout(Widget):
if state and not confirmed:
def confirm_callback(result: DialogResult):
if result == DialogResult.CONFIRM:
self._params.put_bool("ExperimentalMode", True)
self._params.put_bool("ExperimentalModeConfirmed", True)
self._params.put_bool("ExperimentalMode", True, block=True)
self._params.put_bool("ExperimentalModeConfirmed", True, block=True)
else:
self._toggles["ExperimentalMode"].action_item.set_state(False)
self._update_experimental_mode_icon()
@@ -230,16 +230,16 @@ class TogglesLayout(Widget):
gui_app.push_widget(dlg)
else:
self._update_experimental_mode_icon()
self._params.put_bool("ExperimentalMode", state)
self._params.put_bool("ExperimentalMode", state, block=True)
def _toggle_callback(self, state: bool, param: str):
if param == "ExperimentalMode":
self._handle_experimental_mode_toggle(state)
return
self._params.put_bool(param, state)
self._params.put_bool(param, state, block=True)
if self._toggle_defs[param][3]:
self._params.put_bool("OnroadCycleRequested", True)
self._params.put_bool("OnroadCycleRequested", True, block=True)
def _set_longitudinal_personality(self, button_index: int):
self._params.put("LongitudinalPersonality", button_index)
self._params.put("LongitudinalPersonality", button_index, block=True)
+1 -1
View File
@@ -65,7 +65,7 @@ class PrimeState:
with self._lock:
if prime_type != self.prime_type:
self.prime_type = prime_type
self._params.put_nonblocking("PrimeType", int(prime_type))
self._params.put("PrimeType", int(prime_type))
cloudlog.info(f"Prime type updated to {prime_type}")
def _worker_thread(self) -> None:
+1 -1
View File
@@ -182,7 +182,7 @@ class MiciHomeLayout(Widget):
# long gating for experimental mode - only allow toggle if longitudinal control is available
if ui_state.has_longitudinal_control:
self._experimental_mode = not self._experimental_mode
ui_state.params.put("ExperimentalMode", self._experimental_mode)
ui_state.params.put("ExperimentalMode", self._experimental_mode, block=True)
self._mouse_down_t = None
self._did_long_press = True
+9 -9
View File
@@ -69,7 +69,7 @@ class TrainingGuidePreDMTutorial(NavScroller):
def show_event(self):
super().show_event()
# Get driver monitoring model ready for next step
ui_state.params.put_bool_nonblocking("IsDriverViewEnabled", True)
ui_state.params.put_bool("IsDriverViewEnabled", True)
class DMBadFaceDetected(NavScroller):
@@ -109,7 +109,7 @@ class TrainingGuideDMTutorial(NavWidget):
# Disable driver monitoring model when device times out for inactivity
def inactivity_callback():
ui_state.params.put_bool_nonblocking("IsDriverViewEnabled", False)
ui_state.params.put_bool("IsDriverViewEnabled", False)
device.add_interactive_timeout_callback(inactivity_callback)
@@ -121,7 +121,7 @@ class TrainingGuideDMTutorial(NavWidget):
def _update_state(self):
super()._update_state()
if device.awake and not ui_state.params.get_bool("IsDriverViewEnabled"):
ui_state.params.put_bool_nonblocking("IsDriverViewEnabled", True)
ui_state.params.put_bool("IsDriverViewEnabled", True)
sm = ui_state.sm
if sm.recv_frame.get("driverMonitoringState", 0) == 0:
@@ -217,11 +217,11 @@ class TrainingGuideRecordFront(NavScroller):
super().__init__()
def on_accept():
ui_state.params.put_bool_nonblocking("RecordFront", True)
ui_state.params.put_bool("RecordFront", True)
continue_callback()
def on_decline():
ui_state.params.put_bool_nonblocking("RecordFront", False)
ui_state.params.put_bool("RecordFront", False)
continue_callback()
self._accept_button = BigConfirmationCircleButton("allow data uploading", gui_app.texture("icons_mici/setup/driver_monitoring/dm_check.png", 64, 64),
@@ -353,7 +353,7 @@ class OnboardingWindow(Widget):
self._training_guide.set_enabled(lambda: self.enabled) # for nav stack
def _on_uninstall(self):
ui_state.params.put_bool("DoUninstall", True)
ui_state.params.put_bool("DoUninstall", True, block=True)
def show_event(self):
super().show_event()
@@ -371,15 +371,15 @@ class OnboardingWindow(Widget):
return self._accepted_terms and self._training_done
def close(self):
ui_state.params.put_bool_nonblocking("IsDriverViewEnabled", False)
ui_state.params.put_bool("IsDriverViewEnabled", False)
self._completed_callback()
def _on_terms_accepted(self):
ui_state.params.put("HasAcceptedTerms", terms_version)
ui_state.params.put("HasAcceptedTerms", terms_version, block=True)
gui_app.push_widget(self._training_guide)
def _on_completed_training(self):
ui_state.params.put("CompletedTrainingVersion", training_version)
ui_state.params.put("CompletedTrainingVersion", training_version, block=True)
self.close()
def _render(self, _):
+11 -11
View File
@@ -162,32 +162,32 @@ class DeveloperLayoutMici(NavScroller):
item.set_checked(ui_state.params.get_bool(key))
def _on_joystick_debug_mode(self, state: bool):
ui_state.params.put_bool("JoystickDebugMode", state)
ui_state.params.put_bool("LongitudinalManeuverMode", False)
ui_state.params.put_bool("JoystickDebugMode", state, block=True)
ui_state.params.put_bool("LongitudinalManeuverMode", False, block=True)
self._long_maneuver_toggle.set_checked(False)
ui_state.params.put_bool("LateralManeuverMode", False)
ui_state.params.put_bool("LateralManeuverMode", False, block=True)
self._lat_maneuver_toggle.set_checked(False)
def _on_long_maneuver_mode(self, state: bool):
ui_state.params.put_bool("LongitudinalManeuverMode", state)
ui_state.params.put_bool("JoystickDebugMode", False)
ui_state.params.put_bool("LongitudinalManeuverMode", state, block=True)
ui_state.params.put_bool("JoystickDebugMode", False, block=True)
self._joystick_toggle.set_checked(False)
ui_state.params.put_bool("LateralManeuverMode", False)
ui_state.params.put_bool("LateralManeuverMode", False, block=True)
self._lat_maneuver_toggle.set_checked(False)
restart_needed_callback()
def _on_lat_maneuver_mode(self, state: bool):
ui_state.params.put_bool("LateralManeuverMode", state)
ui_state.params.put_bool("ExperimentalMode", False)
ui_state.params.put_bool("JoystickDebugMode", False)
ui_state.params.put_bool("LateralManeuverMode", state, block=True)
ui_state.params.put_bool("ExperimentalMode", False, block=True)
ui_state.params.put_bool("JoystickDebugMode", False, block=True)
self._joystick_toggle.set_checked(False)
ui_state.params.put_bool("LongitudinalManeuverMode", False)
ui_state.params.put_bool("LongitudinalManeuverMode", False, block=True)
self._long_maneuver_toggle.set_checked(False)
restart_needed_callback()
def _on_alpha_long_enabled(self, state: bool):
def do_toggle(_state: bool):
ui_state.params.put_bool("AlphaLongitudinalEnabled", _state)
ui_state.params.put_bool("AlphaLongitudinalEnabled", _state, block=True)
restart_needed_callback()
self._update_toggles()
+6 -6
View File
@@ -40,7 +40,7 @@ class ReviewTrainingGuide(TrainingGuide):
def hide_event(self):
super().hide_event()
device.set_override_interactive_timeout(None)
ui_state.params.put_bool_nonblocking("IsDriverViewEnabled", False)
ui_state.params.put_bool("IsDriverViewEnabled", False)
class MiciFccModal(NavRawScrollPanel):
@@ -200,7 +200,7 @@ class UpdateOpenpilotBigButton(BigButton):
if self.get_value() == "download update":
os.system("pkill -SIGHUP -f system.updated.updated")
elif self.get_value() == "update now":
ui_state.params.put_bool("DoReboot", True)
ui_state.params.put_bool("DoReboot", True, block=True)
else:
os.system("pkill -SIGUSR1 -f system.updated.updated")
@@ -292,10 +292,10 @@ class DeviceLayoutMici(NavScroller):
self._fcc_dialog: HtmlModal | None = None
def power_off_callback():
ui_state.params.put_bool("DoShutdown", True)
ui_state.params.put_bool("DoShutdown", True, block=True)
def reboot_callback():
ui_state.params.put_bool("DoReboot", True)
ui_state.params.put_bool("DoReboot", True, block=True)
def reset_calibration_callback():
params = ui_state.params
@@ -304,10 +304,10 @@ class DeviceLayoutMici(NavScroller):
params.remove("LiveParameters")
params.remove("LiveParametersV2")
params.remove("LiveDelay")
params.put_bool("OnroadCycleRequested", True)
params.put_bool("OnroadCycleRequested", True, block=True)
def uninstall_openpilot_callback():
ui_state.params.put_bool("DoUninstall", True)
ui_state.params.put_bool("DoUninstall", True, block=True)
reset_calibration_btn = EngagedConfirmationButton("reset calibration", "reset", gui_app.texture("icons_mici/settings/device/lkas.png", 122, 64),
reset_calibration_callback)
@@ -207,7 +207,7 @@ class FirehoseLayoutBase(Widget):
if response.status_code == 200:
data = response.json()
self._segment_count = data.get("firehose", 0)
self._params.put_nonblocking(self.PARAM_KEY, data)
self._params.put(self.PARAM_KEY, data)
except Exception as e:
cloudlog.error(f"Failed to fetch firehose stats: {e}")
@@ -117,7 +117,7 @@ class NetworkLayoutMici(NavScroller):
if apn == "":
ui_state.params.remove("GsmApn")
else:
ui_state.params.put("GsmApn", apn)
ui_state.params.put("GsmApn", apn, block=True)
current_apn = ui_state.params.get("GsmApn") or ""
dlg = BigInputDialog("enter APN...", current_apn, minimum_length=0, confirm_callback=update_apn)
@@ -41,7 +41,7 @@ class BaseDriverCameraDialog(Widget):
def show_event(self):
super().show_event()
ui_state.params.put_bool_nonblocking("IsDriverViewEnabled", True)
ui_state.params.put_bool("IsDriverViewEnabled", True)
self._publish_alert_sound(None)
device.set_override_interactive_timeout(300)
ui_state.params.remove("DriverTooDistracted")
@@ -49,7 +49,7 @@ class BaseDriverCameraDialog(Widget):
def hide_event(self):
super().hide_event()
ui_state.params.put_bool_nonblocking("IsDriverViewEnabled", False)
ui_state.params.put_bool("IsDriverViewEnabled", False)
device.set_override_interactive_timeout(None)
def _handle_mouse_release(self, _):
+3 -3
View File
@@ -387,7 +387,7 @@ class BigMultiParamToggle(BigMultiToggle):
def _handle_mouse_release(self, mouse_pos: MousePos):
super()._handle_mouse_release(mouse_pos)
new_idx = self._options.index(self.value)
self._params.put_nonblocking(self._param, new_idx)
self._params.put(self._param, new_idx)
class BigParamControl(BigToggle):
@@ -399,7 +399,7 @@ class BigParamControl(BigToggle):
def _handle_mouse_release(self, mouse_pos: MousePos):
super()._handle_mouse_release(mouse_pos)
self.params.put_bool(self.param, self._checked)
self.params.put_bool(self.param, self._checked, block=True)
def refresh(self):
self.set_checked(self.params.get_bool(self.param, False))
@@ -416,7 +416,7 @@ class BigCircleParamControl(BigCircleToggle):
def _handle_mouse_release(self, mouse_pos: MousePos):
super()._handle_mouse_release(mouse_pos)
self.params.put_bool(self._param, self._checked)
self.params.put_bool(self._param, self._checked, block=True)
def refresh(self):
self.set_checked(self.params.get_bool(self._param, False))
+2 -2
View File
@@ -15,11 +15,11 @@ class DriverCameraDialog(CameraView):
self.driver_state_renderer = DriverStateRenderer()
# TODO: this can grow unbounded, should be given some thought
device.add_interactive_timeout_callback(gui_app.pop_widget)
ui_state.params.put_bool("IsDriverViewEnabled", True)
ui_state.params.put_bool("IsDriverViewEnabled", True, block=True)
def hide_event(self):
super().hide_event()
ui_state.params.put_bool("IsDriverViewEnabled", False)
ui_state.params.put_bool("IsDriverViewEnabled", False, block=True)
self.close()
def _handle_mouse_release(self, _):
+1 -1
View File
@@ -36,7 +36,7 @@ class ExpButton(Widget):
super()._handle_mouse_release(_)
if self._is_toggle_allowed():
new_mode = not self._experimental_mode
self._params.put_bool_nonblocking("ExperimentalMode", new_mode)
self._params.put_bool("ExperimentalMode", new_mode)
# Hold new state temporarily
self._held_mode = new_mode
+3 -3
View File
@@ -18,11 +18,11 @@ if __name__ == "__main__":
t = 10 if len(sys.argv) < 2 else int(sys.argv[1])
while True:
print("setting alert update")
params.put_bool("UpdateAvailable", True)
params.put("UpdaterNewReleaseNotes", parse_release_notes(BASEDIR))
params.put_bool("UpdateAvailable", True, block=True)
params.put("UpdaterNewReleaseNotes", parse_release_notes(BASEDIR), block=True)
time.sleep(t)
params.put_bool("UpdateAvailable", False)
params.put_bool("UpdateAvailable", False, block=True)
# cycle through normal alerts
for a in offroad_alerts:
+9 -9
View File
@@ -24,17 +24,17 @@ HEADLESS = os.getenv("WINDOWED", "0") != "1"
def setup_state():
params = Params()
params.put("HasAcceptedTerms", terms_version)
params.put("CompletedTrainingVersion", training_version)
params.put("DongleId", "test123456789")
params.put("HasAcceptedTerms", terms_version, block=True)
params.put("CompletedTrainingVersion", training_version, block=True)
params.put("DongleId", "test123456789", block=True)
# Combined description for layouts that still use it (BIG home, settings/software)
params.put("UpdaterCurrentDescription", "0.10.1 / test-branch / abc1234 / Nov 30")
params.put("UpdaterCurrentReleaseNotes", parse_release_notes(BASEDIR))
params.put("UpdaterCurrentDescription", "0.10.1 / test-branch / abc1234 / Nov 30", block=True)
params.put("UpdaterCurrentReleaseNotes", parse_release_notes(BASEDIR), block=True)
# Params for mici home
params.put("Version", "0.10.1")
params.put("GitBranch", "test-branch")
params.put("GitCommit", "abc12340ff9131237ba23a1d0fbd8edf9c80e87")
params.put("GitCommitDate", "'1732924800 2024-11-30 00:00:00 +0000'")
params.put("Version", "0.10.1", block=True)
params.put("GitBranch", "test-branch", block=True)
params.put("GitCommit", "abc12340ff9131237ba23a1d0fbd8edf9c80e87", block=True)
params.put("GitCommitDate", "'1732924800 2024-11-30 00:00:00 +0000'", block=True)
# Patch Api.get_token to return a static token so the pairing QR code is deterministic across runs
Api.get_token = lambda self, payload_extra=None, expiry_hours=0: "test_token"
+9 -9
View File
@@ -126,12 +126,12 @@ def setup_offroad_alerts() -> None:
def setup_update_available(available: bool = True) -> None:
params = Params()
params.put_bool("UpdateAvailable", available)
params.put("UpdaterAvailableBranches", ",".join(["test-branch", "test-branch-2", BRANCH_NAME]))
params.put_bool("UpdateAvailable", available, block=True)
params.put("UpdaterAvailableBranches", ",".join(["test-branch", "test-branch-2", BRANCH_NAME]), block=True)
if available:
params.put("UpdaterNewDescription", f"0.10.2 / {BRANCH_NAME} / 0a1b2c3 / Jan 01")
params.put("UpdaterNewReleaseNotes", parse_release_notes(BASEDIR))
params.put("UpdaterTargetBranch", BRANCH_NAME)
params.put("UpdaterNewDescription", f"0.10.2 / {BRANCH_NAME} / 0a1b2c3 / Jan 01", block=True)
params.put("UpdaterNewReleaseNotes", parse_release_notes(BASEDIR), block=True)
params.put("UpdaterTargetBranch", BRANCH_NAME, block=True)
else:
params.remove("UpdaterNewDescription")
params.remove("UpdaterNewReleaseNotes")
@@ -144,22 +144,22 @@ def setup_calibration_params() -> None:
calib = messaging.new_message('liveCalibration')
calib.liveCalibration.calStatus = log.LiveCalibrationData.Status.calibrated
calib.liveCalibration.rpyCalib = [0.0, math.radians(2.5), math.radians(-1.2)]
params.put("CalibrationParams", calib.to_bytes())
params.put("CalibrationParams", calib.to_bytes(), block=True)
# live delay
delay = messaging.new_message('liveDelay')
delay.liveDelay.calPerc = 75
params.put("LiveDelay", delay.to_bytes())
params.put("LiveDelay", delay.to_bytes(), block=True)
# live torque parameters
torque = messaging.new_message('liveTorqueParameters')
torque.liveTorqueParameters.useParams = True
torque.liveTorqueParameters.calPerc = 60
params.put("LiveTorqueParameters", torque.to_bytes())
params.put("LiveTorqueParameters", torque.to_bytes(), block=True)
def setup_developer_params() -> None:
CP = car.CarParams()
CP.alphaLongitudinalAvailable = True
Params().put("CarParamsPersistent", CP.to_bytes())
Params().put("CarParamsPersistent", CP.to_bytes(), block=True)
# --- Send functions ---
+1 -1
View File
@@ -27,7 +27,7 @@ class TestFeedbackd:
@pytest.mark.parametrize("record_feedback", [False, True])
def test_audio_feedback(self, record_feedback):
Params().put_bool("RecordAudioFeedback", record_feedback)
Params().put_bool("RecordAudioFeedback", record_feedback, block=True)
managed_processes["feedbackd"].start()
assert self.pm.wait_for_readers_to_update('carState', timeout=5)
+1 -1
View File
@@ -92,7 +92,7 @@ class AbstractAlert(Widget, ABC):
self.dismiss_callback: Callable | None = None
def snooze_callback():
self.params.put_bool("SnoozeUpdate", True)
self.params.put_bool("SnoozeUpdate", True, block=True)
if self.dismiss_callback:
self.dismiss_callback()
+2 -2
View File
@@ -59,8 +59,8 @@ class SshKeyFetcher:
if not keys:
raise requests.exceptions.HTTPError("No SSH keys found")
self._params.put("GithubUsername", username)
self._params.put("GithubSshKeys", keys)
self._params.put("GithubUsername", username, block=True)
self._params.put("GithubSshKeys", keys, block=True)
except requests.exceptions.Timeout:
self._error = tr("Request timed out")
except Exception:
+3 -3
View File
@@ -161,7 +161,7 @@ class UploadQueueCache:
try:
queue: list[UploadItem | None] = list(upload_queue.queue)
items = [asdict(i) for i in queue if i is not None and (i.id not in cancelled_uploads)]
Params().put("AthenadUploadQueue", items)
Params().put("AthenadUploadQueue", items, block=True)
except Exception:
cloudlog.exception("athena.UploadQueueCache.cache.exception")
@@ -477,7 +477,7 @@ def setRouteViewed(route: str) -> dict[str, int | str]:
# remove duplicates
routes = list(dict.fromkeys(routes))
params.put("AthenadRecentlyViewedRoutes", ",".join(routes[-10:]))
params.put("AthenadRecentlyViewedRoutes", ",".join(routes[-10:]), block=True)
return {"success": 1}
@@ -745,7 +745,7 @@ def ws_recv(ws: WebSocket, end_event: threading.Event) -> None:
recv_queue.put_nowait(data)
elif opcode == ABNF.OPCODE_PING:
last_ping = int(time.monotonic() * 1e9)
Params().put("LastAthenaPingTime", last_ping)
Params().put("LastAthenaPingTime", last_ping, block=True)
except WebSocketTimeoutException:
ns_since_last_ping = int(time.monotonic() * 1e9) - last_ping
if ns_since_last_ping > RECONNECT_TIMEOUT_S * 1e9:
+1 -1
View File
@@ -95,7 +95,7 @@ def register(show_spinner=False) -> str | None:
spinner.close()
if dongle_id:
params.put("DongleId", dongle_id)
params.put("DongleId", dongle_id, block=True)
set_offroad_alert("Offroad_UnregisteredHardware", (dongle_id == UNREGISTERED_DONGLE_ID) and not PC)
return dongle_id
+2 -2
View File
@@ -73,8 +73,8 @@ class TestAthenadMethods:
self.params = Params()
for k, v in self.default_params.items():
self.params.put(k, v)
self.params.put_bool("GsmMetered", True)
self.params.put(k, v, block=True)
self.params.put_bool("GsmMetered", True, block=True)
athenad.upload_queue = queue.PriorityQueue()
athenad.cur_upload_items.clear()
+1 -1
View File
@@ -37,7 +37,7 @@ class TestRegistration:
dongle = "DONGLE_ID_123"
m = mocker.patch("openpilot.system.athena.registration.api_get", autospec=True)
for persist, params in [(True, True), (True, False), (False, True)]:
self.params.put("DongleId", dongle if params else "")
self.params.put("DongleId", dongle if params else "", block=True)
with open(self.dongle_id, "w") as f:
f.write(dongle if persist else "")
assert register() == dongle
+3 -3
View File
@@ -87,7 +87,7 @@ def snapshot():
return None, None
front_camera_allowed = params.get_bool("RecordFront")
params.put_bool("IsTakingSnapshot", True)
params.put_bool("IsTakingSnapshot", True, block=True)
set_offroad_alert("Offroad_IsTakingSnapshot", True)
time.sleep(2.0) # Give hardwared time to read the param, or if just started give camerad time to start
@@ -95,7 +95,7 @@ def snapshot():
try:
subprocess.check_call(["pgrep", "camerad"])
print("Camerad already running")
params.put_bool("IsTakingSnapshot", False)
params.put_bool("IsTakingSnapshot", False, block=True)
params.remove("Offroad_IsTakingSnapshot")
return None, None
except subprocess.CalledProcessError:
@@ -111,7 +111,7 @@ def snapshot():
rear, front = get_snapshots(frame, front_frame)
finally:
managed_processes['camerad'].stop()
params.put_bool("IsTakingSnapshot", False)
params.put_bool("IsTakingSnapshot", False, block=True)
set_offroad_alert("Offroad_IsTakingSnapshot", False)
if not front_camera_allowed:
+8 -8
View File
@@ -206,7 +206,7 @@ def hardware_thread(end_event, hw_queue) -> None:
# handle requests to cycle system started state
if params.get_bool("OnroadCycleRequested"):
params.put_bool("OnroadCycleRequested", False)
params.put_bool("OnroadCycleRequested", False, block=True)
offroad_cycle_count = sm.frame
onroad_conditions["not_onroad_cycle"] = (sm.frame - offroad_cycle_count) >= ONROAD_CYCLE_TIME * SERVICE_LIST['pandaStates'].frequency
@@ -324,13 +324,13 @@ def hardware_thread(end_event, hw_queue) -> None:
should_start = should_start and all(startup_conditions.values())
if should_start != should_start_prev or (count == 0):
params.put_bool("IsEngaged", False)
params.put_bool("IsEngaged", False, block=True)
engaged_prev = False
if sm.updated['selfdriveState']:
engaged = sm['selfdriveState'].enabled
if engaged != engaged_prev:
params.put_bool("IsEngaged", engaged)
params.put_bool("IsEngaged", engaged, block=True)
engaged_prev = engaged
try:
@@ -380,7 +380,7 @@ def hardware_thread(end_event, hw_queue) -> None:
# Check if we need to shut down
if power_monitor.should_shutdown(onroad_conditions["ignition"], in_car, off_ts, started_seen):
cloudlog.warning(f"shutting device down, offroad since {off_ts}")
params.put_bool("DoShutdown", True)
params.put_bool("DoShutdown", True, block=True)
msg.deviceState.started = started_ts is not None
msg.deviceState.startedMonoTime = int(1e9*(started_ts or 0))
@@ -426,11 +426,11 @@ def hardware_thread(end_event, hw_queue) -> None:
# save last one before going onroad
if rising_edge_started:
try:
params.put("LastOffroadStatusPacket", dat)
params.put("LastOffroadStatusPacket", dat, block=True)
except Exception:
cloudlog.exception("failed to save offroad status")
params.put_bool_nonblocking("NetworkMetered", msg.deviceState.networkMetered)
params.put_bool("NetworkMetered", msg.deviceState.networkMetered)
now_ts = time.monotonic()
if off_ts:
@@ -440,8 +440,8 @@ def hardware_thread(end_event, hw_queue) -> None:
last_uptime_ts = now_ts
if (count % int(60. / DT_HW)) == 0:
params.put("UptimeOffroad", uptime_offroad)
params.put("UptimeOnroad", uptime_onroad)
params.put("UptimeOffroad", uptime_offroad, block=True)
params.put("UptimeOnroad", uptime_onroad, block=True)
count += 1
should_start_prev = should_start
+1 -1
View File
@@ -56,7 +56,7 @@ class PowerMonitoring:
self.car_battery_capacity_uWh = max(self.car_battery_capacity_uWh, 0)
self.car_battery_capacity_uWh = min(self.car_battery_capacity_uWh, CAR_BATTERY_CAPACITY_uWh)
if now - self.last_save_time >= 10:
self.params.put_nonblocking("CarBatteryCapacity", int(self.car_battery_capacity_uWh))
self.params.put("CarBatteryCapacity", int(self.car_battery_capacity_uWh))
self.last_save_time = now
# First measurement, set integration time
@@ -139,7 +139,7 @@ class TestPowerMonitoring:
def test_disable_power_down(self, mocker):
POWER_DRAW = 0 # To stop shutting down for other reasons
TEST_TIME = 100
self.params.put_bool("DisablePowerDown", True)
self.params.put_bool("DisablePowerDown", True, block=True)
pm_patch(mocker, "HARDWARE.get_current_power_draw", POWER_DRAW)
pm = PowerMonitoring()
pm.car_battery_capacity_uWh = CAR_BATTERY_CAPACITY_uWh
@@ -42,7 +42,7 @@ PROCS = [
class TestPowerDraw:
def setup_method(self):
Params().put("CarParams", get_demo_car_params().to_bytes())
Params().put("CarParams", get_demo_car_params().to_bytes(), block=True)
# wait a bit for power save to disable
time.sleep(5)
+2 -2
View File
@@ -76,8 +76,8 @@ class UploaderTestCase:
self.seg_dir = self.seg_format.format(self.seg_num)
self.params = Params()
self.params.put("IsOffroad", True)
self.params.put("DongleId", "0000000000000000")
self.params.put("IsOffroad", True, block=True)
self.params.put("DongleId", "0000000000000000", block=True)
def make_file_with_data(self, f_dir: str, fn: str, size_mb: float = .1, lock: bool = False,
upload_xattr: bytes | None = None, preserve_xattr: bytes | None = None) -> Path:
+1 -1
View File
@@ -53,7 +53,7 @@ class TestEncoder:
# TODO: this should run faster than real time
@parameterized.expand([(True, ), (False, )])
def test_log_rotation(self, record_front):
Params().put_bool("RecordFront", record_front)
Params().put_bool("RecordFront", record_front, block=True)
managed_processes['sensord'].start()
managed_processes['loggerd'].start()
+5 -5
View File
@@ -161,8 +161,8 @@ class TestLoggerd:
]
params = Params()
for k, _, v in fake_params:
params.put(k, v)
params.put("AccessToken", "abc")
params.put(k, v, block=True)
params.put("AccessToken", "abc", block=True)
lr = list(LogReader(str(self._gen_bootlog())))
initData = lr[0].initData
@@ -188,7 +188,7 @@ class TestLoggerd:
@pytest.mark.xdist_group("camera_encoder_tests") # setting xdist group ensures tests are run in same worker, prevents encoderd from crashing
def test_rotation(self):
Params().put("RecordFront", True)
Params().put("RecordFront", True, block=True)
expected_files = {"rlog.zst", "qlog.zst", "qcamera.ts", "fcamera.hevc", "dcamera.hevc", "ecamera.hevc"}
@@ -309,7 +309,7 @@ class TestLoggerd:
@pytest.mark.parametrize("record_front", [True, False])
def test_record_front(self, record_front):
params = Params()
params.put_bool("RecordFront", record_front)
params.put_bool("RecordFront", record_front, block=True)
self._publish_camera_and_audio_messages()
@@ -320,7 +320,7 @@ class TestLoggerd:
@pytest.mark.parametrize("record_audio", [True, False])
def test_record_audio(self, record_audio):
params = Params()
params.put_bool("RecordAudio", record_audio)
params.put_bool("RecordAudio", record_audio, block=True)
self._publish_camera_and_audio_messages()
+2 -2
View File
@@ -46,8 +46,8 @@ def unblock_stdout() -> None:
def write_onroad_params(started, params):
params.put_bool("IsOnroad", started)
params.put_bool("IsOffroad", not started)
params.put_bool("IsOnroad", started, block=True)
params.put_bool("IsOffroad", not started, block=True)
def save_bootlog():
+11 -11
View File
@@ -36,13 +36,13 @@ def manager_init() -> None:
params.clear_all(ParamKeyFlag.DEVELOPMENT_ONLY)
if params.get_bool("RecordFrontLock"):
params.put_bool("RecordFront", True)
params.put_bool("RecordFront", True, block=True)
# set unset params to their default value
for k in params.all_keys():
default_value = params.get_default_value(k)
if default_value is not None and params.get(k) is None:
params.put(k, default_value)
params.put(k, default_value, block=True)
# Create folders needed for msgq
try:
@@ -54,14 +54,14 @@ def manager_init() -> None:
# set params
serial = HARDWARE.get_serial()
params.put("Version", build_metadata.openpilot.version)
params.put("GitCommit", build_metadata.openpilot.git_commit)
params.put("GitCommitDate", build_metadata.openpilot.git_commit_date)
params.put("GitBranch", build_metadata.channel)
params.put("GitRemote", build_metadata.openpilot.git_origin)
params.put_bool("IsTestedBranch", build_metadata.tested_channel)
params.put_bool("IsReleaseBranch", build_metadata.release_channel)
params.put("HardwareSerial", serial)
params.put("Version", build_metadata.openpilot.version, block=True)
params.put("GitCommit", build_metadata.openpilot.git_commit, block=True)
params.put("GitCommitDate", build_metadata.openpilot.git_commit_date, block=True)
params.put("GitBranch", build_metadata.channel, block=True)
params.put("GitRemote", build_metadata.openpilot.git_origin, block=True)
params.put_bool("IsTestedBranch", build_metadata.tested_channel, block=True)
params.put_bool("IsReleaseBranch", build_metadata.release_channel, block=True)
params.put("HardwareSerial", serial, block=True)
# set dongle id
reg_res = register(show_spinner=True)
@@ -173,7 +173,7 @@ def manager_thread() -> None:
for param in ("DoUninstall", "DoShutdown", "DoReboot"):
if params.get_bool(param):
shutdown = True
params.put("LastManagerExitReason", f"{param} {datetime.datetime.now()}")
params.put("LastManagerExitReason", f"{param} {datetime.datetime.now()}", block=True)
cloudlog.warning(f"Shutting down manager - {param} set")
if shutdown:
+1 -1
View File
@@ -240,7 +240,7 @@ class DaemonProcess(ManagerProcess):
stderr=open('/dev/null', 'w'),
preexec_fn=os.setpgrp)
self.params.put(self.param_name, proc.pid)
self.params.put(self.param_name, proc.pid, block=True)
def stop(self, retry=True, block=True, sig=None) -> None:
pass
+1 -1
View File
@@ -28,7 +28,7 @@ def ublox_available() -> bool:
def ublox(started: bool, params: Params, CP: car.CarParams) -> bool:
use_ublox = ublox_available()
if use_ublox != params.get_bool("UbloxAvailable"):
params.put_bool("UbloxAvailable", use_ublox)
params.put_bool("UbloxAvailable", use_ublox, block=True)
return started and use_ublox
def joystick(started: bool, params: Params, CP: car.CarParams) -> bool:
+1 -1
View File
@@ -176,7 +176,7 @@ class Multilang:
self._plurals = {}
def change_language(self, language_code: str) -> None:
self._params.put("LanguageSetting", language_code)
self._params.put("LanguageSetting", language_code, block=True)
self._language = language_code
self.setup()
+3 -3
View File
@@ -175,7 +175,7 @@ class AdvancedNetworkSettings(Widget):
self._wifi_manager.set_tethering_active(checked)
def _toggle_roaming(self):
self._params.put_bool("GsmRoaming", self._roaming_action.get_state())
self._params.put_bool("GsmRoaming", self._roaming_action.get_state(), block=True)
def _edit_apn(self):
def update_apn(result: DialogResult):
@@ -186,7 +186,7 @@ class AdvancedNetworkSettings(Widget):
if apn == "":
self._params.remove("GsmApn")
else:
self._params.put("GsmApn", apn)
self._params.put("GsmApn", apn, block=True)
current_apn = self._params.get("GsmApn") or ""
self._keyboard.reset(min_text_size=0)
@@ -196,7 +196,7 @@ class AdvancedNetworkSettings(Widget):
gui_app.push_widget(self._keyboard)
def _toggle_cellular_metered(self):
self._params.put_bool("GsmMetered", self._cellular_metered_action.get_state())
self._params.put_bool("GsmMetered", self._cellular_metered_action.get_state(), block=True)
def _toggle_wifi_metered(self, metered):
metered_type = {0: MeteredType.UNKNOWN, 1: MeteredType.YES, 2: MeteredType.NO}.get(metered, MeteredType.UNKNOWN)
+1 -1
View File
@@ -86,7 +86,7 @@ class TestBaseUpdate:
mocker.patch("openpilot.common.basedir.BASEDIR", self.basedir)
def set_target_branch(self, branch):
self.params.put("UpdaterTargetBranch", branch)
self.params.put("UpdaterTargetBranch", branch, block=True)
def setup_basedir_release(self, release):
self.params = Params()
+1 -1
View File
@@ -28,7 +28,7 @@ def test_target_branch_migration_from_current_branch(mocker, device_type, branch
])
def test_target_branch_migration_from_param(mocker, device_type, branch, expected):
params = Params()
params.put("UpdaterTargetBranch", branch)
params.put("UpdaterTargetBranch", branch, block=True)
mocker.patch("openpilot.system.updated.updated.HARDWARE.get_device_type", return_value=device_type)
+23 -23
View File
@@ -66,7 +66,7 @@ class WaitTimeHelper:
def write_time_to_param(params, param) -> None:
t = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
params.put(param, t)
params.put(param, t, block=True)
def run(cmd: list[str], cwd: str | None = None) -> str:
return subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT, encoding='utf8')
@@ -139,7 +139,7 @@ def init_overlay() -> None:
cloudlog.info("preparing new safe staging area")
params = Params()
params.put_bool("UpdateAvailable", False)
params.put_bool("UpdateAvailable", False, block=True)
set_consistent_flag(False)
dismount_overlay()
run(["sudo", "rm", "-rf", STAGING_ROOT])
@@ -170,7 +170,7 @@ def init_overlay() -> None:
run(["sudo", "chmod", "755", os.path.join(OVERLAY_METADATA, "work")])
git_diff = run(["git", "diff", "--submodule=diff"], OVERLAY_MERGED)
params.put("GitDiff", git_diff)
params.put("GitDiff", git_diff, block=True)
cloudlog.info(f"git diff output:\n{git_diff}")
@@ -275,19 +275,19 @@ class Updater:
return run(["git", "rev-parse", "HEAD"], path).rstrip()
def set_params(self, update_success: bool, failed_count: int, exception: str | None) -> None:
self.params.put("UpdateFailedCount", failed_count)
self.params.put("UpdaterTargetBranch", self.target_branch)
self.params.put("UpdateFailedCount", failed_count, block=True)
self.params.put("UpdaterTargetBranch", self.target_branch, block=True)
self.params.put_bool("UpdaterFetchAvailable", self.update_available)
self.params.put_bool("UpdaterFetchAvailable", self.update_available, block=True)
if len(self.branches):
self.params.put("UpdaterAvailableBranches", ','.join(self.branches.keys()))
self.params.put("UpdaterAvailableBranches", ','.join(self.branches.keys()), block=True)
last_uptime_onroad = self.params.get("UptimeOnroad", return_default=True)
last_route_count = self.params.get("RouteCount", return_default=True)
if update_success:
self.params.put("LastUpdateTime", datetime.datetime.now(datetime.UTC).replace(tzinfo=None))
self.params.put("LastUpdateUptimeOnroad", last_uptime_onroad)
self.params.put("LastUpdateRouteCount", last_route_count)
self.params.put("LastUpdateTime", datetime.datetime.now(datetime.UTC).replace(tzinfo=None), block=True)
self.params.put("LastUpdateUptimeOnroad", last_uptime_onroad, block=True)
self.params.put("LastUpdateRouteCount", last_route_count, block=True)
else:
last_uptime_onroad = self.params.get("LastUpdateUptimeOnroad", return_default=True)
last_route_count = self.params.get("LastUpdateRouteCount", return_default=True)
@@ -295,7 +295,7 @@ class Updater:
if exception is None:
self.params.remove("LastUpdateException")
else:
self.params.put("LastUpdateException", exception)
self.params.put("LastUpdateException", exception, block=True)
# Write out current and new version info
def get_description(basedir: str) -> str:
@@ -318,11 +318,11 @@ class Updater:
except Exception:
cloudlog.exception("updater.get_description")
return f"{version} / {branch} / {commit} / {commit_date}"
self.params.put("UpdaterCurrentDescription", get_description(BASEDIR))
self.params.put("UpdaterCurrentReleaseNotes", parse_release_notes(BASEDIR))
self.params.put("UpdaterNewDescription", get_description(FINALIZED))
self.params.put("UpdaterNewReleaseNotes", parse_release_notes(FINALIZED))
self.params.put_bool("UpdateAvailable", self.update_ready)
self.params.put("UpdaterCurrentDescription", get_description(BASEDIR), block=True)
self.params.put("UpdaterCurrentReleaseNotes", parse_release_notes(BASEDIR), block=True)
self.params.put("UpdaterNewDescription", get_description(FINALIZED), block=True)
self.params.put("UpdaterNewReleaseNotes", parse_release_notes(FINALIZED), block=True)
self.params.put_bool("UpdateAvailable", self.update_ready, block=True)
# Handle user prompt
for alert in ("Offroad_UpdateFailed", "Offroad_ConnectivityNeeded", "Offroad_ConnectivityNeededPrompt"):
@@ -377,11 +377,11 @@ class Updater:
def fetch_update(self) -> None:
cloudlog.info("attempting git fetch inside staging overlay")
self.params.put("UpdaterState", "downloading...")
self.params.put("UpdaterState", "downloading...", block=True)
# TODO: cleanly interrupt this and invalidate old update
set_consistent_flag(False)
self.params.put_bool("UpdateAvailable", False)
self.params.put_bool("UpdateAvailable", False, block=True)
setup_git_options(OVERLAY_MERGED)
@@ -409,7 +409,7 @@ class Updater:
handle_agnos_update()
# Create the finalized, ready-to-swap update
self.params.put("UpdaterState", "finalizing update...")
self.params.put("UpdaterState", "finalizing update...", block=True)
finalize_update()
cloudlog.info("finalize success!")
@@ -438,7 +438,7 @@ def main() -> None:
if not params.get("InstallDate"):
t = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
params.put("InstallDate", t)
params.put("InstallDate", t, block=True)
updater = Updater()
update_failed_count = 0 # TODO: Load from param?
@@ -448,7 +448,7 @@ def main() -> None:
set_consistent_flag(False)
# set initial state
params.put("UpdaterState", "idle")
params.put("UpdaterState", "idle", block=True)
# Run the update loop
first_run = True
@@ -472,7 +472,7 @@ def main() -> None:
update_failed_count += 1
# check for update
params.put("UpdaterState", "checking...")
params.put("UpdaterState", "checking...", block=True)
updater.check_for_update()
# download update
@@ -502,7 +502,7 @@ def main() -> None:
OVERLAY_INIT.unlink(missing_ok=True)
try:
params.put("UpdaterState", "idle")
params.put("UpdaterState", "idle", block=True)
update_successful = (update_failed_count == 0)
updater.set_params(update_successful, update_failed_count, exception)
except Exception:
+1 -1
View File
@@ -69,7 +69,7 @@ async def offer(request: 'web.Request'):
def main():
# Enable joystick debug mode
Params().put_bool("JoystickDebugMode", True)
Params().put_bool("JoystickDebugMode", True, block=True)
# App needs to be HTTPS for WebRTC to work on the browser
ssl_context = create_ssl_context()
+1 -1
View File
@@ -219,7 +219,7 @@ def load_route_metadata(route):
params = Params()
for entry in init_data.params.entries:
try:
params.put(entry.key, params.cpp2python(entry.key, entry.value))
params.put(entry.key, params.cpp2python(entry.key, entry.value), block=True)
except UnknownKeyName:
pass
+1 -1
View File
@@ -110,7 +110,7 @@ def send_thread(joystick):
def joystick_control_thread(joystick):
Params().put_bool('JoystickDebugMode', True)
Params().put_bool('JoystickDebugMode', True, block=True)
threading.Thread(target=send_thread, args=(joystick,), daemon=True).start()
while True:
joystick.update()
+3 -3
View File
@@ -15,9 +15,9 @@ if __name__ == "__main__":
if keys.status_code == 200:
params = Params()
params.put_bool("SshEnabled", True)
params.put("GithubSshKeys", keys.text)
params.put("GithubUsername", username)
params.put_bool("SshEnabled", True, block=True)
params.put("GithubSshKeys", keys.text, block=True)
params.put("GithubUsername", username, block=True)
print("Set up ssh keys successfully")
else:
print("Error getting public keys from github")
+1 -1
View File
@@ -40,7 +40,7 @@ class SimulatorBridge(ABC):
def __init__(self, dual_camera, high_quality):
set_params_enabled()
self.params = Params()
self.params.put_bool("AlphaLongitudinalEnabled", True)
self.params.put_bool("AlphaLongitudinalEnabled", True, block=True)
self.rk = Ratekeeper(100, None)
+1 -1
View File
@@ -84,7 +84,7 @@ class SimulatedCar:
if self.params.get_bool("ObdMultiplexingEnabled") != self.obd_multiplexing:
self.obd_multiplexing = not self.obd_multiplexing
self.params.put_bool("ObdMultiplexingChanged", True)
self.params.put_bool("ObdMultiplexingChanged", True, block=True)
dat = messaging.new_message('pandaStates', 1)
dat.valid = True