Here a we go

This commit is contained in:
firestar5683
2026-08-17 06:36:55 -05:00
parent b567d9fc90
commit 161ecbc1ab
16 changed files with 311 additions and 29 deletions
+2 -2
View File
@@ -384,8 +384,8 @@ class Controls:
self.ecu_disable_failed = self.params.get_bool("EcuDisableFailed")
self.ecu_disable_failed_checked = True
if self.ecu_disable_failed and self.CP.carFingerprint == NISSAN_CAR.NISSAN_LEAF:
self.CP.openpilotLongitudinalControl = False
self.CP.pcmCruise = True
self.CP = messaging.log_from_bytes(self.params.get("CarParams"), car.CarParams)
self.FPCP = messaging.log_from_bytes(self.params.get("StarPilotCarParams"), custom.StarPilotCarParams)
def state_control(self):
CS = self.sm['carState']
@@ -0,0 +1,56 @@
import cereal.messaging as messaging
from cereal import car, custom
from opendbc.car.nissan.values import CAR as NISSAN_CAR
from openpilot.selfdrive.car.cruise_state import should_cancel_stock_cruise
from openpilot.selfdrive.controls.controlsd import Controls
class FakeFallbackParams:
def __init__(self, fallback_cp, fallback_fpcp):
self.values = {
"CarParams": fallback_cp.to_bytes(),
"StarPilotCarParams": fallback_fpcp.to_bytes(),
}
def get_bool(self, key):
return key in ("ControlsReady", "EcuDisableFailed")
def get(self, key):
return self.values[key]
def test_leaf_ecu_disable_fallback_reloads_read_only_car_params():
initial_cp = car.CarParams.new_message()
initial_cp.carFingerprint = NISSAN_CAR.NISSAN_LEAF
initial_cp.openpilotLongitudinalControl = True
initial_cp.pcmCruise = False
initial_fpcp = custom.StarPilotCarParams.new_message()
initial_fpcp.safetyConfigs = [custom.StarPilotCarParams.SafetyConfig.new_message(safetyParam=2)]
fallback_cp = car.CarParams.new_message()
fallback_cp.carFingerprint = NISSAN_CAR.NISSAN_LEAF
fallback_cp.openpilotLongitudinalControl = False
fallback_cp.pcmCruise = True
fallback_fpcp = custom.StarPilotCarParams.new_message()
fallback_fpcp.safetyConfigs = [custom.StarPilotCarParams.SafetyConfig.new_message(safetyParam=0)]
initial_cp_reader = messaging.log_from_bytes(initial_cp.to_bytes(), car.CarParams)
controls = Controls.__new__(Controls)
controls.CP = initial_cp_reader
controls.FPCP = messaging.log_from_bytes(initial_fpcp.to_bytes(), custom.StarPilotCarParams)
controls.params = FakeFallbackParams(fallback_cp, fallback_fpcp)
controls.ecu_disable_failed = False
controls.ecu_disable_failed_checked = False
controls.update_ecu_disable_failed()
assert controls.ecu_disable_failed
assert controls.ecu_disable_failed_checked
assert not controls.CP.openpilotLongitudinalControl
assert controls.CP.pcmCruise
assert controls.FPCP.safetyConfigs[0].safetyParam == 0
assert initial_cp_reader.openpilotLongitudinalControl
assert not initial_cp_reader.pcmCruise
assert not should_cancel_stock_cruise(controls.CP, cruise_enabled=True, controls_enabled=True)
+3 -5
View File
@@ -297,11 +297,9 @@ class SelfdriveD:
self.ecu_disable_failed = self.params.get_bool("EcuDisableFailed")
self.ecu_disable_failed_checked = True
if self.ecu_disable_failed:
fallback_cp = messaging.log_from_bytes(self.params.get("CarParams"), car.CarParams)
fallback_fpcp = messaging.log_from_bytes(self.params.get("StarPilotCarParams"), custom.StarPilotCarParams)
self.CP.openpilotLongitudinalControl = fallback_cp.openpilotLongitudinalControl
self.CP.pcmCruise = fallback_cp.pcmCruise
self.FPCP = fallback_fpcp
self.CP = messaging.log_from_bytes(self.params.get("CarParams"), car.CarParams)
self.FPCP = messaging.log_from_bytes(self.params.get("StarPilotCarParams"), custom.StarPilotCarParams)
self.car_events = CarSpecificEvents(self.CP)
def clear_longitudinal_excessive_actuation_alert(self):
alert = self.params.get("Offroad_ExcessiveActuation")
+22 -5
View File
@@ -1,4 +1,6 @@
from cereal import car, custom
import cereal.messaging as messaging
from cereal import car, custom, log
from opendbc.car.hyundai.values import CAR as HYUNDAI_CAR
from opendbc.car.nissan.values import CAR as NISSAN_CAR
@@ -63,8 +65,9 @@ def test_ecu_disable_fallback_synchronizes_behavior_and_safety_params():
fallback_fpcp.safetyConfigs = [custom.StarPilotCarParams.SafetyConfig.new_message(safetyParam=0)]
selfdrived = SelfdriveD.__new__(SelfdriveD)
selfdrived.CP = initial_cp
selfdrived.FPCP = initial_fpcp
initial_cp_reader = messaging.log_from_bytes(initial_cp.to_bytes(), car.CarParams)
selfdrived.CP = initial_cp_reader
selfdrived.FPCP = messaging.log_from_bytes(initial_fpcp.to_bytes(), custom.StarPilotCarParams)
selfdrived.params = FakeFallbackParams(True, True, fallback_cp, fallback_fpcp)
selfdrived.ecu_disable_failed = False
selfdrived.ecu_disable_failed_checked = False
@@ -76,6 +79,16 @@ def test_ecu_disable_fallback_synchronizes_behavior_and_safety_params():
assert not selfdrived.CP.openpilotLongitudinalControl
assert selfdrived.CP.pcmCruise
assert selfdrived.FPCP.safetyConfigs[0].safetyParam == 0
assert initial_cp_reader.openpilotLongitudinalControl
assert not initial_cp_reader.pcmCruise
CS = car.CarState.new_message()
CS.gearShifter = car.CarState.GearShifter.drive
CS.cruiseState.available = True
CS.cruiseState.enabled = True
CS_prev = car.CarState.new_message()
events = selfdrived.car_events.update(CS, CS_prev, car.CarControl.new_message())
assert log.OnroadEvent.EventName.pcmEnable in events.names
def test_ecu_disable_fallback_does_not_change_other_cars():
@@ -93,8 +106,10 @@ def test_ecu_disable_fallback_does_not_change_other_cars():
fallback_fpcp.safetyConfigs = [custom.StarPilotCarParams.SafetyConfig.new_message(safetyParam=0)]
selfdrived = SelfdriveD.__new__(SelfdriveD)
selfdrived.CP = initial_cp
selfdrived.FPCP = initial_fpcp
initial_cp_reader = messaging.log_from_bytes(initial_cp.to_bytes(), car.CarParams)
initial_fpcp_reader = messaging.log_from_bytes(initial_fpcp.to_bytes(), custom.StarPilotCarParams)
selfdrived.CP = initial_cp_reader
selfdrived.FPCP = initial_fpcp_reader
selfdrived.params = FakeFallbackParams(True, True, fallback_cp, fallback_fpcp)
selfdrived.ecu_disable_failed = False
selfdrived.ecu_disable_failed_checked = False
@@ -105,3 +120,5 @@ def test_ecu_disable_fallback_does_not_change_other_cars():
assert selfdrived.CP.openpilotLongitudinalControl
assert not selfdrived.CP.pcmCruise
assert selfdrived.FPCP.safetyConfigs[0].safetyParam == 4
assert selfdrived.CP is initial_cp_reader
assert selfdrived.FPCP is initial_fpcp_reader