diff --git a/opendbc_repo/opendbc/car/gm/aol.py b/opendbc_repo/opendbc/car/gm/aol.py index 23e400bd5d..2d17a037d9 100644 --- a/opendbc_repo/opendbc/car/gm/aol.py +++ b/opendbc_repo/opendbc/car/gm/aol.py @@ -28,7 +28,7 @@ GM_AOL_WORDS = (frozenset(range(0xE600, 0xE608)) | frozenset(range(0xE610, 0xE61 0, 16, 0x80, 0xE100, 0xE101, 0xE102, 0xE103, 0xE110, 0xE111, 0xE112, 0xE113, 0xD100, 0xD101, 0xD102, 0xD103, 0xD104, 0xD105, 0xD106, 0xD107, 0xD108, 0xD109, 0xD10A, 0xD110, 0xD111, 0xD112, 0xD113, 0xD114, 0xD115, 0xD116, 0xD117, 0xD118, 0xD119, 0xD11A, - 0x1001, 0x1401, 0x3001, 0x3401, 0x1003, 0x1403, + 0xE900, 0x1001, 0x1401, 0x3001, 0x3401, 0x1003, 0x1403, 0x201, 0x601, 0xA01, 0xE01, 0x203, 0x603, 0xA03, 0xE03, 5, 7, 20, 0xBD, 0x9D, 0x19D, 0x1CD, 0x205, 0x605, 0xA05, 0xE05, 0x4207, 0x4607, 0x4A07, 0x4E07, diff --git a/opendbc_repo/opendbc/car/gm/fingerprints.py b/opendbc_repo/opendbc/car/gm/fingerprints.py index 1ee9ff002e..0e502e6349 100644 --- a/opendbc_repo/opendbc/car/gm/fingerprints.py +++ b/opendbc_repo/opendbc/car/gm/fingerprints.py @@ -7,6 +7,7 @@ from opendbc.car.gm.values import CAR FINGERPRINTS = { + CAR.BUICK_ENVISION_SDGM: [{190: 3, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 311: 8, 413: 8, 451: 8, 452: 8, 453: 6, 455: 7, 479: 3, 485: 8, 489: 8, 500: 6, 501: 8, 562: 8, 707: 8, 801: 8, 840: 5, 977: 8, 1001: 8}], CAR.CHEVROLET_TRAX: [{ 190: 6, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 257: 8, 288: 5, 298: 8, 304: 3, 309: 8, 311: 8, 313: 8, 320: 4, 322: 7, 328: 1, 352: 5, 381: 8, 384: 4, 386: 8, 388: 8, 413: 8, 451: 8, 452: 8, 453: 6, 455: 7, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 500: 6, diff --git a/opendbc_repo/opendbc/car/gm/interface.py b/opendbc_repo/opendbc/car/gm/interface.py index 097e0dc4f7..f208b63008 100644 --- a/opendbc_repo/opendbc/car/gm/interface.py +++ b/opendbc_repo/opendbc/car/gm/interface.py @@ -27,6 +27,7 @@ TransmissionType = structs.CarParams.TransmissionType NetworkLocation = structs.CarParams.NetworkLocation NON_LINEAR_TORQUE_PARAMS = { + CAR.BUICK_ENVISION_SDGM: [2.4, 1.05, 0.20, 0.0], CAR.CHEVROLET_BOLT_EUV: [2.6531724862969748, 1.0, 0.1919764879840985, 0.009054123646805178], CAR.GMC_ACADIA: [4.78003305, 1.0, 0.3122, 0.05591772], CAR.CHEVROLET_SILVERADO: [3.29974374, 1.0, 0.25571356, 0.0465122] @@ -493,6 +494,15 @@ class CarInterface(CarInterfaceBase): ret.steerActuatorDelay = 0.2 CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) + elif candidate == CAR.BUICK_ENVISION_SDGM: + ret.minEnableSpeed = -1. + ret.steerActuatorDelay = 0.2 + ret.alphaLongitudinalAvailable = False + ret.openpilotLongitudinalControl = False + ret.pcmCruise = True + ret.safetyConfigs[0].safetyParam = 0xE900 + CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) + elif candidate in (CAR.BUICK_LACROSSE, CAR.BUICK_LACROSSE_ASCM, CAR.BUICK_LACROSSE_ASCM_19US): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) if candidate == CAR.BUICK_LACROSSE_ASCM_19US: diff --git a/opendbc_repo/opendbc/car/gm/tests/test_envision_sdgm.py b/opendbc_repo/opendbc/car/gm/tests/test_envision_sdgm.py new file mode 100644 index 0000000000..314330b9de --- /dev/null +++ b/opendbc_repo/opendbc/car/gm/tests/test_envision_sdgm.py @@ -0,0 +1,50 @@ +"""PR232 retrofit identity is isolated from ordinary GM configurations.""" +import unittest +from opendbc.car import gen_empty_fingerprint +from opendbc.car.gm.interface import CarInterface +from opendbc.car.gm.values import CAR, is_ordinary_sdgm_profile +from opendbc.car.gm.fingerprints import FINGERPRINTS +from opendbc.car.gm.aol import qualified_gm + + +def envision_params(alpha=False): + fingerprint = gen_empty_fingerprint() + fingerprint[0] = FINGERPRINTS[CAR.BUICK_ENVISION_SDGM][0] + return CarInterface.get_params(CAR.BUICK_ENVISION_SDGM, fingerprint, [], alpha, False, False) + + +class TestEnvisionSdgm(unittest.TestCase): + def test_exact_stock_profile(self): + for alpha in (False, True): + cp = envision_params(alpha) + self.assertEqual(cp.safetyConfigs[0].safetyParam, 0xE900) + self.assertTrue(cp.pcmCruise) + self.assertFalse(cp.openpilotLongitudinalControl) + self.assertFalse(cp.alphaLongitudinalAvailable) + self.assertTrue(is_ordinary_sdgm_profile(cp, longitudinal=False)) + self.assertTrue(qualified_gm(cp)) + CarInterface(cp) + + def test_owner_cannot_be_borrowed(self): + for identity in CAR: + if identity == CAR.BUICK_ENVISION_SDGM: + continue + cp = envision_params() + cp.carFingerprint = identity + self.assertFalse(qualified_gm(cp), str(identity)) + for word in (0x1001, 0x1003, 0xE901, 0x3001): + cp = envision_params() + cp.safetyConfigs[0].safetyParam = word + self.assertFalse(qualified_gm(cp), hex(word)) + + def test_analog_source_and_custom_frame_length(self): + from opendbc.car.gm.carstate import CarState + from opendbc.car import Bus + from opendbc.can import CANPacker + from opendbc.car.gm.values import DBC + cp = envision_params() + state = CarState(cp) + parser = state.get_can_parsers(cp)[Bus.pt] + self.assertIn('ECMAcceleratorPos', parser.vl) + packer = CANPacker(DBC[cp.carFingerprint][Bus.pt]) + self.assertEqual(len(packer.make_can_msg('ECMAcceleratorPos', 0, {'BrakePedalPos': 10})[1]), 3) diff --git a/opendbc_repo/opendbc/car/gm/tests/test_ordinary_bsm.py b/opendbc_repo/opendbc/car/gm/tests/test_ordinary_bsm.py index 4dfd5442ad..de63c01e37 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_ordinary_bsm.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_ordinary_bsm.py @@ -7,7 +7,7 @@ from opendbc.car.gm.carstate import CarState from opendbc.car.gm.tests.test_ascm_intercept import params from opendbc.car.gm.tests.test_bolt_cc import native from opendbc.safety.tests.libsafety import libsafety_py -from opendbc.car.gm.values import (DBC, GMFlags, ORDINARY_ASCM_CAR, ORDINARY_SDGM_CAR, +from opendbc.car.gm.values import (CAR, DBC, GMFlags, ORDINARY_ASCM_CAR, ORDINARY_SDGM_CAR, is_ordinary_ascm_profile, is_ordinary_sdgm_profile) from openpilot.starpilot.aol.tests import test_gm_startup_continuity as startup @@ -25,7 +25,7 @@ def test_bsm_preserves_exact_control_owners(candidate): cp = params(candidate, sascm=True, accelerator=accelerator, radar=radar, alpha=alpha, release=release) word = cp.safetyConfigs[0].safetyParam cp.flags |= int(GMFlags.HAS_BSM) - longitudinal = alpha and not release + longitudinal = alpha and not release and candidate != CAR.BUICK_ENVISION_SDGM assert profile(cp, longitudinal=longitudinal) assert qualified_gm(cp) assert cp.safetyConfigs[0].safetyParam == word @@ -43,6 +43,13 @@ def test_bsm_startup_replaces_all_acc_messages_on_correct_buses(candidate): cp = params(candidate, sascm=True, alpha=True) cp.flags |= int(GMFlags.HAS_BSM) controller = CarController(DBC[candidate], cp) + if candidate == CAR.BUICK_ENVISION_SDGM: + assert not cp.alphaLongitudinalAvailable + assert not cp.openpilotLongitudinalControl + assert not controller.startup_acc_keepalive + assert not controller.ordinary_sdgm_long + assert qualified_gm(cp) + return assert controller.startup_acc_keepalive assert controller.ordinary_sdgm_long == (candidate in ORDINARY_SDGM_CAR) state = CarState(cp) diff --git a/opendbc_repo/opendbc/car/gm/tests/test_ordinary_sdgm.py b/opendbc_repo/opendbc/car/gm/tests/test_ordinary_sdgm.py index 9f21a569fe..5bc46c2ac0 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_ordinary_sdgm.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_ordinary_sdgm.py @@ -8,17 +8,19 @@ from opendbc.car.gm.ordinary import demands class TestOrdinarySdgm(unittest.TestCase): def test_exact_final_configuration(self): - self.assertEqual(len(ORDINARY_SDGM_CAR), 7) + self.assertEqual(len(ORDINARY_SDGM_CAR), 8) for candidate in ORDINARY_SDGM_CAR: for release in (False, True): for alpha in (False, True): for sascm in (False, True): for c9 in (False, True): cp = params(candidate, sascm=sascm, accelerator=not c9, alpha=alpha, release=release) - long = alpha and sascm and not release + long = alpha and sascm and not release and candidate != CAR.BUICK_ENVISION_SDGM expected = 0x1001 | (2 if long else 0) | (0x400 if c9 else 0) if not long and candidate in SDGM_CANCEL_PT_CAR: expected |= 0x2000 + if candidate == CAR.BUICK_ENVISION_SDGM: + expected = 0xE900 self.assertEqual(cp.safetyConfigs[0].safetyParam, expected) self.assertTrue(is_ordinary_sdgm_profile(cp, longitudinal=long)) self.assertEqual(sdgm_policy_for(cp) is not None, long) @@ -47,7 +49,7 @@ class TestOrdinarySdgm(unittest.TestCase): from opendbc.car.gm.carstate import CarState from opendbc.car.gm.values import DBC for candidate in ORDINARY_SDGM_CAR: - for c9 in (False, True): + for c9 in ((False,) if candidate == CAR.BUICK_ENVISION_SDGM else (False, True)): cp = params(candidate, sascm=True, accelerator=not c9, alpha=True) state = CarState(cp) parsers = state.get_can_parsers(cp) @@ -79,7 +81,7 @@ class TestOrdinarySdgm(unittest.TestCase): for release in (False, True): for alpha in (False, True): cp = params(candidate, sascm=True, alpha=alpha, release=release) - self.assertEqual(longitudinal_supported(cp), alpha and not release) + self.assertEqual(longitudinal_supported(cp), alpha and not release and candidate != CAR.BUICK_ENVISION_SDGM) self.assertTrue(lane_centering_supported(cp)) self.assertTrue(qualified_gm(cp)) self.assertEqual(policy_for(cp), 'ordinary_sdgm') diff --git a/opendbc_repo/opendbc/car/gm/tests/test_sdgm_acc_startup.py b/opendbc_repo/opendbc/car/gm/tests/test_sdgm_acc_startup.py index c1de68d649..7bf8d3f757 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_sdgm_acc_startup.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_sdgm_acc_startup.py @@ -19,6 +19,11 @@ class TestSdgmAccStartup(unittest.TestCase): cp = params(identity, sascm=True, accelerator=not c9, alpha=True) cp.alternativeExperience = 32 ci = CarInterface(cp) + if identity == CAR.BUICK_ENVISION_SDGM: + self.assertFalse(cp.alphaLongitudinalAvailable) + self.assertFalse(ci.CC.ordinary_sdgm_long) + self.assertFalse(ci.CC.startup_acc_keepalive) + continue self.assertTrue(ci.CC.ordinary_sdgm_long) packer = CANPacker(DBC[identity][Bus.pt]) safety = native.libsafety diff --git a/opendbc_repo/opendbc/car/gm/values.py b/opendbc_repo/opendbc/car/gm/values.py index 2c49732af5..7beb13b10a 100644 --- a/opendbc_repo/opendbc/car/gm/values.py +++ b/opendbc_repo/opendbc/car/gm/values.py @@ -156,6 +156,8 @@ VOLT_ONE_PEDAL_WORDS = {start + index: word for start in (0xD100, 0xD110) def gm_control_word(cp: CarParams) -> int: word = int(cp.safetyConfigs[0].safetyParam) + if word == 0xE900 and cp.carFingerprint == CAR.BUICK_ENVISION_SDGM: + return 0x1001 if word in VOLT_ONE_PEDAL_WORDS: index = word - (0xD110 if word >= 0xD110 else 0xD100) identity = (CAR.CHEVROLET_VOLT if index < 2 else CAR.CHEVROLET_VOLT_ASCM if index < 6 else @@ -561,6 +563,11 @@ class CAR(Platforms): GMC_ACADIA_ASCM = GMPlatformConfig( [GMCommunityCarDocs("GMC Acadia (ASCM Harness) 2018")], GMC_ACADIA.specs, ) + BUICK_ENVISION_SDGM = GMPlatformConfig( + [GMCommunityCarDocs("Buick Envision (CN SDGM Retrofit) 2016", "Custom cross-flashed ADAS stack and SDGM harness")], + GMCarSpecs(mass=1800, wheelbase=2.75, steerRatio=15.6, centerToFrontRatio=0.41), + dbc_dict={Bus.pt: 'gm_global_a_powertrain_envision', Bus.radar: 'gm_global_a_object', Bus.chassis: 'gm_global_a_chassis'}, + ) BUICK_LACROSSE = GMPlatformConfig( [GMCommunityCarDocs("Buick LaCrosse (OBD-II Harness) 2017-19", "Driver Confidence Package 2")], GMCarSpecs(mass=1712, wheelbase=2.91, steerRatio=15.8, centerToFrontRatio=0.4), @@ -846,7 +853,7 @@ SDGM_STOCK_CAR = { CAR.CHEVROLET_BLAZER, CAR.CHEVROLET_MALIBU_SDGM, } SDGM_CANCEL_PT_CAR = {CAR.CADILLAC_XT4, CAR.CADILLAC_XT5, CAR.CADILLAC_XT6, CAR.BUICK_BABYENCLAVE} -SDGM_CAR = {CAR.CADILLAC_XT4, CAR.CHEVROLET_VOLT_2019, CAR.CHEVROLET_TRAVERSE} | SDGM_STOCK_CAR +SDGM_CAR = {CAR.BUICK_ENVISION_SDGM, CAR.CADILLAC_XT4, CAR.CHEVROLET_VOLT_2019, CAR.CHEVROLET_TRAVERSE} | SDGM_STOCK_CAR CC_GATEWAY_STOCK_CAR = { CAR.CADILLAC_CT6_CC, CAR.CADILLAC_XT4_CC, CAR.CADILLAC_XT5_CC, @@ -1000,6 +1007,9 @@ ORDINARY_SDGM_CAR = SDGM_CAR - {CAR.CHEVROLET_VOLT_2019} def is_ordinary_sdgm_profile(cp, *, longitudinal): """Exact ordinary SDGM source and authority selection.""" try: + envision = cp.carFingerprint == CAR.BUICK_ENVISION_SDGM + if envision and (longitudinal or cp.alphaLongitudinalAvailable or int(cp.safetyConfigs[0].safetyParam) != 0xE900): + return False required = int(GMSafetyFlags.HW_CAM | GMSafetyFlags.SDGM) if longitudinal: required |= int(GMSafetyFlags.HW_CAM_LONG) @@ -1013,7 +1023,7 @@ def is_ordinary_sdgm_profile(cp, *, longitudinal): cp.openpilotLongitudinalControl == longitudinal and cp.pcmCruise != longitudinal and (not longitudinal or cp.alphaLongitudinalAvailable) and len(configs) == 1 and configs[0].safetyModel == CarParams.SafetyModel.gm and - int(configs[0].safetyParam) & ~optional == required) + (gm_control_word(cp) if envision else int(configs[0].safetyParam)) & ~optional == required) except (AttributeError, IndexError, TypeError, ValueError): return False diff --git a/opendbc_repo/opendbc/car/torque_data/override.toml b/opendbc_repo/opendbc/car/torque_data/override.toml index f88802e5b0..0b7ff41762 100644 --- a/opendbc_repo/opendbc/car/torque_data/override.toml +++ b/opendbc_repo/opendbc/car/torque_data/override.toml @@ -178,3 +178,5 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "VOLVO_XC40_RECHARGE" = [1.5, 1.5, 0.1] "VOLVO_S60_RECHARGE" = [1.5, 1.5, 0.1] + +"BUICK_ENVISION_SDGM" = [2.6, 2.5, 0.14] diff --git a/opendbc_repo/opendbc/dbc/gm_global_a_powertrain_envision.dbc b/opendbc_repo/opendbc/dbc/gm_global_a_powertrain_envision.dbc new file mode 100644 index 0000000000..6c1be08957 --- /dev/null +++ b/opendbc_repo/opendbc/dbc/gm_global_a_powertrain_envision.dbc @@ -0,0 +1,387 @@ +CM_ "AUTOGENERATED FILE, DO NOT EDIT"; + + +CM_ "Imported file _community.dbc starts here"; +BO_ 512 GAS_COMMAND: 6 NEO + SG_ GAS_COMMAND : 7|16@0+ (0.125677,-75.909) [0|1] "" INTERCEPTOR + SG_ GAS_COMMAND2 : 23|16@0+ (0.251976,-76.601) [0|1] "" INTERCEPTOR + SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR + SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR + SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR + +BO_ 513 GAS_SENSOR: 6 INTERCEPTOR + SG_ INTERCEPTOR_GAS : 7|16@0+ (0.125677,-75.909) [0|1] "" NEO + SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.251976,-76.601) [0|1] "" NEO + SG_ STATE : 39|4@0+ (1,0) [0|15] "" NEO + SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" NEO + SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" NEO + +VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; + +CM_ "gm_global_a_powertrain.dbc starts here"; + +VERSION "" + + +NS_ : + NS_DESC_ + CM_ + BA_DEF_ + BA_ + VAL_ + CAT_DEF_ + CAT_ + FILTER + BA_DEF_DEF_ + EV_DATA_ + ENVVAR_DATA_ + SGTYPE_ + SGTYPE_VAL_ + BA_DEF_SGTYPE_ + BA_SGTYPE_ + SIG_TYPE_REF_ + VAL_TABLE_ + SIG_GROUP_ + SIG_VALTYPE_ + SIGTYPE_VALTYPE_ + BO_TX_BU_ + BA_DEF_REL_ + BA_REL_ + BA_DEF_DEF_REL_ + BU_SG_REL_ + BU_EV_REL_ + BU_BO_REL_ + SG_MUL_VAL_ + +BS_: + +BU_: K16_BECM K73_TCIC K9_BCM K43_PSCM K17_EBCM K20_ECM K114B_HPCM NEO K124_ASCM EPB +VAL_TABLE_ TurnSignals 2 "Right Turn" 1 "Left Turn" 0 "None" ; +VAL_TABLE_ Intellibeam 1 "Active" 0 "Inactive" ; +VAL_TABLE_ HighBeamsActive 1 "Active" 0 "Inactive" ; +VAL_TABLE_ HighBeamsTemporary 1 "Active" 0 "Inactive" ; +VAL_TABLE_ ACCLeadCar 1 "Present" 0 "Not Present" ; +VAL_TABLE_ ACCCmdActive 1 "Active" 0 "Inactive" ; +VAL_TABLE_ BrakePedalPressed 1 "Pressed" 0 "Depressed" ; +VAL_TABLE_ DistanceButton 1 "Active" 0 "Inactive" ; +VAL_TABLE_ LKAButton 1 "Active" 0 "Inactive" ; +VAL_TABLE_ ACCButtons 6 "Cancel" 5 "Main" 3 "Set" 2 "Resume" 1 "None" ; +VAL_TABLE_ DriveModeButton 1 "Active" 0 "Inactive" ; +VAL_TABLE_ PRNDL 3 "Reverse" 2 "Drive" 1 "Neutral" 0 "Park" ; +VAL_TABLE_ ESPButton 1 "Active" 0 "Inactive" ; +VAL_TABLE_ DoorStatus 1 "Opened" 0 "Closed" ; +VAL_TABLE_ SeatBeltStatus 1 "Latched" 0 "Unlatched" ; +VAL_TABLE_ LKASteeringCmdActive 1 "Active" 0 "Inactive" ; +VAL_TABLE_ ACCGapLevel 3 "Far" 2 "Med" 1 "Near" 0 "Inactive" ; +VAL_TABLE_ GasRegenCmdActiveInv 1 "Inactive" 0 "Active" ; +VAL_TABLE_ GasRegenCmdActive 1 "Active" 0 "Inactive" ; +VAL_TABLE_ LKATorqueDeliveredStatus 3 "Failed" 2 "Temp. Limited" 1 "Active" 0 "Inactive" ; +VAL_TABLE_ HandsOffSWDetectionStatus 1 "Hands On" 0 "Hands Off" ; +VAL_TABLE_ HandsOffSWDetectionMode 2 "Failed" 1 "Enabled" 0 "Disabled" ; + + +BO_ 189 EBCMRegenPaddle: 7 K17_EBCM + SG_ RegenPaddle : 7|4@0+ (1,0) [0|0] "" NEO + SG_ Byte1 : 15|8@0+ (1,0) [0|255] "" NEO + SG_ Byte2 : 23|8@0+ (1,0) [0|255] "" NEO + SG_ Byte3 : 31|8@0+ (1,0) [0|255] "" NEO + SG_ Byte4 : 39|8@0+ (1,0) [0|255] "" NEO + SG_ Byte5 : 47|8@0+ (1,0) [0|255] "" NEO + SG_ Byte6 : 55|8@0+ (1,0) [0|255] "" NEO + +BO_ 190 ECMAcceleratorPos: 3 K20_ECM + SG_ BrakePedalPos : 15|8@0+ (1,0) [0|0] "sticky" NEO + SG_ GasPedalAndAcc : 23|8@0+ (1,0) [0|0] "" NEO + +BO_ 201 ECMEngineStatus: 8 K20_ECM + SG_ EngineTPS : 39|8@0+ (0.392156863,0) [0|100.000000065] "%" NEO + SG_ EngineRPM : 15|16@0+ (0.25,0) [0|0] "RPM" NEO + SG_ CruiseMainOn : 29|1@0+ (1,0) [0|1] "" NEO + SG_ BrakePressed : 40|1@0+ (1,0) [0|1] "" NEO + SG_ Standstill : 2|1@0+ (1,0) [0|1] "" NEO + SG_ CruiseActive : 31|2@0+ (1,0) [0|3] "" NEO + +BO_ 209 EBCMBrakePedalSensors: 7 K17_EBCM + SG_ Counter1 : 7|2@0+ (1,0) [0|3] "" XXX + SG_ Counter2 : 23|2@0+ (1,0) [0|3] "" XXX + SG_ BrakePedalPosition1 : 5|14@0+ (1,0) [0|16383] "" XXX + SG_ BrakePedalPosition2 : 21|14@0- (-1,0) [0|16383] "" XXX + SG_ BrakeNormalized1 : 39|8@0+ (1,0) [0|255] "" XXX + SG_ BrakeNormalized2 : 47|8@0- (-1,0) [0|255] "" XXX + +BO_ 241 EBCMBrakePedalPosition: 6 K17_EBCM + SG_ BrakePressed : 1|1@0+ (1,0) [0|1] "" XXX + SG_ BrakePedalPosition : 15|8@0+ (1,0) [0|255] "" NEO + +BO_ 298 BCMDoorBeltStatus: 8 K9_BCM + SG_ RearLeftDoor : 8|1@0+ (1,0) [0|0] "" NEO + SG_ FrontLeftDoor : 9|1@0+ (1,0) [0|0] "" NEO + SG_ FrontRightDoor : 10|1@0+ (1,0) [0|0] "" NEO + SG_ RearRightDoor : 23|1@0+ (1,0) [0|0] "" NEO + SG_ LeftSeatBelt : 12|1@0+ (1,0) [0|0] "" NEO + SG_ RightSeatBelt : 53|1@0+ (1,0) [0|0] "" NEO + +BO_ 309 ECMPRDNL: 8 K20_ECM + SG_ PRNDL : 2|3@0+ (1,0) [0|0] "" NEO + SG_ ESPButton : 4|1@0+ (1,0) [0|1] "" XXX + +BO_ 320 BCMTurnSignals: 3 K9_BCM + SG_ TurnSignals : 19|2@0+ (1,0) [0|0] "" NEO + SG_ Intellibeam : 13|1@0+ (1,0) [0|1] "" XXX + SG_ HighBeamsActive : 7|1@0+ (1,0) [0|1] "" XXX + SG_ HighBeamsTemporary : 5|1@0+ (1,0) [0|1] "" XXX + +BO_ 322 BCMBlindSpotMonitor: 4 K9_BCM + SG_ LeftBSM : 6|1@0+ (1,0) [0|1] "" XXX + SG_ RightBSM : 7|1@0+ (1,0) [0|1] "" XXX + +BO_ 328 PSCM_148: 1 K43_PSCM + +BO_ 381 ESPStatus: 6 K20_ECM + SG_ TractionControlOn : 5|1@0+ (1,0) [0|0] "" NEO + SG_ MSG17D_AccPower : 35|12@0- (1,0) [0|0] "" NEO + +BO_ 384 ASCMLKASteeringCmd: 4 NEO + SG_ RollingCounter : 5|2@0+ (1,0) [0|0] "" NEO + SG_ LKASteeringCmdChecksum : 19|12@0+ (1,0) [0|0] "" NEO + SG_ LKASteeringCmdActive : 3|1@0+ (1,0) [0|0] "" NEO + SG_ LKASteeringCmd : 2|11@0- (1,0) [0|0] "" NEO + +BO_ 388 PSCMStatus: 8 K43_PSCM + SG_ HandsOffSWDetectionMode : 20|2@0+ (1,0) [0|3] "" NEO + SG_ HandsOffSWlDetectionStatus : 21|1@0+ (1,0) [0|1] "" NEO + SG_ LKATorqueDeliveredStatus : 5|3@0+ (1,0) [0|7] "" NEO + SG_ LKADriverAppldTrq : 50|11@0- (0.01,0) [-10.24|10.23] "Nm" NEO + SG_ LKATorqueDelivered : 18|11@0- (0.01,0) [0|1] "" NEO + SG_ LKATotalTorqueDelivered : 2|11@0- (0.01,0) [-10.24|10.23] "Nm" NEO + SG_ RollingCounter : 38|4@0+ (1,0) [0|15] "" XXX + SG_ PSCMStatusChecksum : 33|10@0+ (1,0) [0|1023] "" XXX + +BO_ 417 AcceleratorPedal: 7 XXX + SG_ AcceleratorPedal : 55|8@0+ (1,0) [0|0] "" NEO + +BO_ 451 GasAndAcc: 8 XXX + SG_ GasPedalAndAcc2 : 55|8@0+ (1,0) [0|0] "" NEO + +BO_ 452 AcceleratorPedal2: 8 XXX + SG_ CruiseState : 15|3@0+ (1,0) [0|7] "" NEO + SG_ AcceleratorPedal2 : 47|8@0+ (1,0) [0|0] "" NEO + +BO_ 481 ASCMSteeringButton: 7 K124_ASCM + SG_ DistanceButton : 22|1@0+ (1,0) [0|0] "" NEO + SG_ LKAButton : 23|1@0+ (1,0) [0|0] "" NEO + SG_ ACCAlwaysOne : 24|1@0+ (1,0) [0|1] "" XXX + SG_ ACCButtons : 46|3@0+ (1,0) [0|0] "" NEO + SG_ ACCButtonsHard : 26|2@0+ (1,0) [0|3] "" XXX + SG_ DriveModeButton : 39|1@0+ (1,0) [0|1] "" XXX + SG_ RollingCounter : 33|2@0+ (1,0) [0|3] "" NEO + SG_ SteeringButtonChecksum : 43|12@0+ (1,0) [0|255] "" NEO + +BO_ 485 PSCMSteeringAngle: 8 K43_PSCM + SG_ SteeringWheelAngle : 15|16@0- (0.0625,0) [-2047|2047] "deg" NEO + SG_ SteeringWheelRate : 27|12@0- (1,0) [-2047|2047] "deg/s" NEO + +BO_ 489 EBCMVehicleDynamic: 8 K17_EBCM + SG_ BrakePedalPressed : 6|1@0+ (1,0) [0|0] "" NEO + SG_ LateralAcceleration : 3|10@0- (0.161,0) [-2047|2047] "m/s2" NEO + SG_ YawRate : 35|12@0- (0.625,0) [0|1] "" NEO + SG_ YawRate2 : 51|12@0- (0.0625,0) [-2047|2047] "grad/s" NEO + +BO_ 352 BCMImmobilizer: 5 K9_BCM + SG_ ImmobilizerInfo : 7|32@0+ (1,0) [0|4294967295] "" XXX + +BO_ 497 BCMGeneralPlatformStatus: 8 K9_BCM + SG_ SystemPowerMode : 1|2@0+ (1,0) [0|3] "" XXX + SG_ SystemBackUpPowerMode : 5|2@0+ (1,0) [0|3] "" XXX + SG_ ParkBrakeSwActive : 36|1@0+ (1,0) [0|3] "" XXX + +BO_ 500 SportMode: 6 XXX + SG_ SnowIceMode : 9|1@0+ (1,0) [0|1] "" XXX + SG_ SportMode : 15|1@0+ (1,0) [0|1] "" XXX + SG_ TourMode : 23|1@0+ (1,0) [0|1] "" XXX + SG_ 4WDMode : 21|1@0+ (1,0) [0|1] "" XXX + +BO_ 501 ECMPRDNL2: 8 K20_ECM + SG_ Byte0 : 7|8@0+ (1,0) [0|255] "" NEO + SG_ Byte1 : 15|8@0+ (1,0) [0|255] "" NEO + SG_ Byte2 : 23|8@0+ (1,0) [0|255] "" NEO + SG_ TransmissionState : 48|4@1+ (1,0) [0|7] "" NEO + SG_ PRNDL2 : 27|4@0+ (1,0) [0|255] "" NEO + SG_ Byte4 : 39|8@0+ (1,0) [0|255] "" NEO + SG_ ManualMode : 41|1@0+ (1,0) [0|1] "" NEO + SG_ Byte7 : 63|8@0+ (1,0) [0|255] "" NEO + +BO_ 532 BRAKE_RELATED: 6 XXX + SG_ UserBrakePressure : 0|9@0+ (1,0) [0|511] "" XXX + +BO_ 560 EPBStatus: 8 EPB + SG_ EPBClosed : 12|1@0+ (1,0) [0|1] "" NEO + +BO_ 562 EBCMFrictionBrakeStatus: 8 K17_EBCM + SG_ FrictionBrakeUnavailable : 46|1@0+ (1,0) [0|1] "" XXX + +BO_ 608 SPEED_RELATED: 8 XXX + SG_ RollingCounter : 5|2@0+ (1,0) [0|0] "" XXX + SG_ ClusterSpeed : 31|8@0+ (1,0) [0|0] "" XXX + +BO_ 711 BECMBatteryVoltageCurrent: 6 K17_EBCM + SG_ HVBatteryVoltage : 31|12@0+ (0.125,0) [0|511.875] "V" NEO + SG_ HVBatteryCurrent : 12|13@0- (0.15,0) [-614.4|614.25] "A" NEO + +BO_ 715 ASCMGasRegenCmd: 8 K124_ASCM + SG_ GasRegenAccType : 15|2@0+ (1,0) [0|3] "" NEO + SG_ GasRegenChecksum : 32|25@0+ (1,0) [0|0] "" NEO + SG_ GasRegenFullStopActive : 13|1@0+ (1,0) [0|0] "" NEO + SG_ GasRegenCmdActive : 0|1@0+ (1,0) [0|0] "" NEO + SG_ RollingCounter : 7|2@0+ (1,0) [0|0] "" NEO + SG_ GasRegenCmd : 10|19@0+ (0.125,-22534) [-22534|43001.875] "Nm" NEO + +BO_ 717 ASCM_2CD: 5 K124_ASCM + +BO_ 761 BRAKE_RELATED_2: 7 XXX + SG_ UserBrakePressure2 : 47|9@0+ (1,0) [0|511] "" XXX + +BO_ 789 EBCMFrictionBrakeCmd: 5 K124_ASCM + SG_ RollingCounter : 33|2@0+ (1,0) [0|0] "" NEO + SG_ FrictionBrakeMode : 7|4@0+ (1,0) [0|0] "" NEO + SG_ FrictionBrakeChecksum : 23|16@0+ (1,0) [0|0] "" NEO + SG_ FrictionBrakeCmd : 3|12@0- (1,0) [0|0] "" NEO + +BO_ 800 AEBCmd: 6 K124_ASCM + SG_ RollingCounter : 5|2@0+ (1,0) [0|3] "" NEO + SG_ AEBChecksum : 27|20@0+ (1,0) [0|0] "" NEO + SG_ AEBCmdActive : 3|1@1+ (1,0) [0|1] "" NEO + SG_ AEBCmd : 2|11@0+ (1,0) [0|0] "" NEO + SG_ AEBCmd2 : 23|8@0+ (1,0) [0|0] "" NEO + +BO_ 810 TCICOnStarGPSPosition: 8 K73_TCIC + SG_ GPSLongitude : 39|32@0+ (1,-2147483648) [0|0] "milliarcsecond" NEO + SG_ GPSLatitude : 7|32@0+ (1,0) [0|0] "milliarcsecond" NEO + +BO_ 840 EBCMWheelSpdFront: 5 K17_EBCM + SG_ FLWheelSpd : 7|16@0+ (0.0311,0) [0|255] "km/h" NEO + SG_ FRWheelSpd : 23|16@0+ (0.0311,0) [0|255] "km/h" NEO + +BO_ 842 EBCMWheelSpdRear: 5 K17_EBCM + SG_ RLWheelSpd : 7|16@0+ (0.0311,0) [0|255] "km/h" NEO + SG_ RRWheelSpd : 23|16@0+ (0.0311,0) [0|255] "km/h" NEO + SG_ RRWheelDir : 34|3@0+ (1,0) [0|7] "" NEO + SG_ RLWheelDir : 37|3@0+ (1,0) [0|7] "" NEO + +BO_ 869 ASCM_365: 4 K124_ASCM + +BO_ 880 ASCMActiveCruiseControlStatus: 6 K124_ASCM + SG_ ACCCruiseState : 8|3@1+ (1,0) [0|7] "" XXX + SG_ ACCLeadCar : 44|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ ACCAlwaysOne2 : 32|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ ACCAlwaysOne : 0|1@0+ (1,0) [0|0] "" Vector__XXX + SG_ ACCSpeedSetpoint : 19|12@0+ (0.0625,0) [0|255.9375] "km/h" NEO + SG_ ACCGapLevel : 21|2@0+ (1,0) [0|0] "" NEO + SG_ ACCResumeButton : 1|1@0+ (1,0) [0|0] "" NEO + SG_ ACCCmdActive : 23|1@0+ (1,0) [0|0] "" NEO + SG_ FCWAlert : 41|2@0+ (1,0) [0|3] "" XXX + +BO_ 967 EVDriveMode: 4 XXX + SG_ SinglePedalModeActive : 7|1@0+ (1,0) [0|1] "" XXX + SG_ SinglePedalModeRisingEdge : 21|1@0+ (1,0) [0|1] "" XXX + SG_ SinglePedalModeFallingEdge : 22|1@0+ (1,0) [0|1] "" XXX + +BO_ 977 ECMCruiseControl: 8 K20_ECM + SG_ CruiseActive : 39|1@0+ (1,0) [0|3] "" NEO + SG_ CruiseSetSpeed : 19|12@0+ (0.0625,0) [0|0] "km/h" NEO + +BO_ 1001 ECMVehicleSpeed: 8 K20_ECM + SG_ VehicleSpeed : 7|16@0+ (0.01,0) [0|0] "mph" NEO + SG_ VehicleSpeedLeft : 39|16@0+ (0.01,0) [0|0] "mph" NEO + +BO_ 1033 ASCMKeepAlive: 7 NEO + SG_ ASCMKeepAliveAllZero : 7|56@0+ (1,0) [0|0] "" NEO + +BO_ 1034 ASCM_40A: 7 K124_ASCM + +BO_ 1217 ECMEngineCoolantTemp: 8 K20_ECM + SG_ EngineCoolantTemp : 23|8@0+ (1,-40) [0|0] "C" NEO + +BO_ 1249 VIN_Part2: 8 K20_ECM + SG_ VINPart2 : 7|64@0+ (1,0) [0|0] "" NEO + +BO_ 1296 ASCM_510: 4 K124_ASCM + +BO_ 1300 VIN_Part1: 8 K20_ECM + SG_ VINPart1 : 7|64@0+ (1,0) [0|0] "" NEO + +BO_ 1912 PSCM_778: 8 K43_PSCM + +BO_ 1930 ASCM_78A: 7 K124_ASCM + +BO_TX_BU_ 384 : K124_ASCM,NEO; +BO_TX_BU_ 880 : NEO,K124_ASCM; +BO_TX_BU_ 1033 : K124_ASCM,NEO; +BO_TX_BU_ 715 : NEO,K124_ASCM; +BO_TX_BU_ 789 : NEO,K124_ASCM; +BO_TX_BU_ 800 : NEO,K124_ASCM; + + +CM_ BU_ K16_BECM "Battery Energy Control Module"; +CM_ BU_ K73_TCIC "Telematics Communication Control Module"; +CM_ BU_ K9_BCM "Body Control Module"; +CM_ BU_ K43_PSCM "Power Steering Control Module"; +CM_ BU_ K17_EBCM "Electronic Brake Control Module"; +CM_ BU_ K20_ECM "Engine Control Module"; +CM_ BU_ K114B_HPCM "Hybrid Powertrain Control Module"; +CM_ BU_ NEO "Comma NEO"; +CM_ BU_ K124_ASCM "Active Safety Control Module"; +CM_ SG_ 381 MSG17D_AccPower "Need to investigate"; +CM_ BO_ 190 "Length varies from 6 to 8 bytes by car"; +CM_ SG_ 190 GasPedalAndAcc "ACC baseline is 62"; +CM_ SG_ 322 LeftBSM "For some cars, this can only be when the blinker is also active"; +CM_ SG_ 322 RightBSM "For some cars, this can only be when the blinker is also active"; +CM_ SG_ 352 ImmobilizerInfo "Non-zero when ignition or accessory mode"; +CM_ SG_ 451 GasPedalAndAcc2 "ACC baseline is 62"; +CM_ SG_ 481 ACCAlwaysOne "Usually 1 if the car is equipped with ACC"; +CM_ SG_ 562 FrictionBrakeUnavailable "1 when ACC brake control is unavailable. Stays high if brake command messages are blocked for a period of time"; +CM_ SG_ 497 SystemPowerMode "Describes ignition"; +CM_ SG_ 497 SystemBackUpPowerMode "Describes ignition + preconditioning mode, noisy"; +CM_ SG_ 501 PRNDL2 "When ManualMode is Active, Value is 13=L1 12=L2 11=L3 ... 5=Full 70kW Paddle Regen Unlocked for Gen2 Bolts 4=L10"; +CM_ SG_ 532 UserBrakePressure "can be lower than other brake position signals when the brakes are pre-filled from ACC braking and the user presses on the brakes. user-only pressure?"; +CM_ SG_ 608 ClusterSpeed "Cluster speed signal seems to match dash on newer cars, but is a lower rate and can be noisier."; +CM_ SG_ 761 UserBrakePressure2 "Similar to BRAKE_RELATED->UserBrakePressure"; +CM_ SG_ 1001 VehicleSpeed "Spinouts show here on 2wd. Speed derived from right front wheel (drive tire)"; +BA_DEF_ "UseGMParameterIDs" INT 0 0; +BA_DEF_ "ProtocolType" STRING ; +BA_DEF_ "BusType" STRING ; +BA_DEF_DEF_ "UseGMParameterIDs" 1; +BA_DEF_DEF_ "ProtocolType" "GMLAN"; +BA_DEF_DEF_ "BusType" ""; +BA_ "BusType" "CAN"; +BA_ "ProtocolType" "GMLAN"; +BA_ "UseGMParameterIDs" 0; +VAL_ 497 SystemPowerMode 3 "Crank Request" 2 "Run" 1 "Accessory" 0 "Off"; +VAL_ 497 SystemBackUpPowerMode 3 "Crank Request" 2 "Run" 1 "Accessory" 0 "Off"; +VAL_ 481 DistanceButton 1 "Active" 0 "Inactive" ; +VAL_ 481 LKAButton 1 "Active" 0 "Inactive" ; +VAL_ 481 ACCButtons 6 "Cancel" 5 "Main" 3 "Set" 2 "Resume" 1 "None" ; +VAL_ 481 DriveModeButton 1 "Active" 0 "Inactive" ; +VAL_ 452 CruiseState 4 "Standstill" 3 "Faulted" 1 "Active" 0 "Off" ; +VAL_ 309 PRNDL 3 "R" 2 "D" 1 "N" 0 "P" ; +VAL_ 309 ESPButton 1 "Active" 0 "Inactive" ; +VAL_ 384 LKASteeringCmdActive 1 "Active" 0 "Inactive" ; +VAL_ 842 RRWheelDir 0 "Stationary" 1 "Forward" 2 "Reverse" 3 "Unsupported" 4 "Fault"; +VAL_ 842 RLWheelDir 0 "Stationary" 1 "Forward" 2 "Reverse" 3 "Unsupported" 4 "Fault"; +VAL_ 880 ACCCruiseState 2 "Adaptive" 3 "Adaptive" 4 "Non-adaptive" 5 "Non-adaptive" ; +VAL_ 880 ACCLeadCar 1 "Present" 0 "Not Present" ; +VAL_ 880 ACCGapLevel 3 "Far" 2 "Med" 1 "Near" 0 "Inactive" ; +VAL_ 880 ACCResumeButton 1 "Pressed" 0 "Depressed" ; +VAL_ 880 ACCCmdActive 1 "Active" 0 "Inactive" ; +VAL_ 388 HandsOffSWDetectionMode 2 "Failed" 1 "Enabled" 0 "Disabled" ; +VAL_ 388 HandsOffSWlDetectionStatus 1 "Hands On" 0 "Hands Off" ; +VAL_ 388 LKATorqueDeliveredStatus 3 "Failed" 2 "Temp. Limited" 1 "Active" 0 "Inactive" ; +VAL_ 489 BrakePedalPressed 1 "Pressed" 0 "Depressed" ; +VAL_ 715 GasRegenCmdActiveInv 1 "Inactive" 0 "Active" ; +VAL_ 715 GasRegenCmdActive 1 "Active" 0 "Inactive" ; +VAL_ 320 Intellibeam 1 "Active" 0 "Inactive" ; +VAL_ 320 HighBeamsActive 1 "Active" 0 "Inactive" ; +VAL_ 320 HighBeamsTemporary 1 "Active" 0 "Inactive" ; +VAL_ 501 PRNDL2 7 "L3" 6 "L" 5 "L2" 4 "D" 3 "N" 2 "R" 1 "P" 0 "Shifting"; +VAL_ 501 TransmissionState 11 "Shifting" 10 "Reverse" 9 "Forward" 8 "Disengaged"; +VAL_ 501 ManualMode 1 "Active" 0 "Inactive" diff --git a/opendbc_repo/opendbc/safety/modes/gm.h b/opendbc_repo/opendbc/safety/modes/gm.h index 53061baf7d..d9341bc47c 100644 --- a/opendbc_repo/opendbc/safety/modes/gm.h +++ b/opendbc_repo/opendbc/safety/modes/gm.h @@ -911,7 +911,8 @@ static bool gm_fwd_hook(int bus_num, int addr) { } static safety_config gm_init(uint16_t safety_param) { - uint16_t bolt_param = safety_param; + const bool envision_sdgm = safety_param == 0xE900U; + uint16_t bolt_param = envision_sdgm ? 0x1001U : safety_param; gm_bolt_pedal_removed = false; gm_bolt_removed_acc_seen = false; gm_bolt_removed_gear_seen = false; @@ -1863,6 +1864,15 @@ static safety_config gm_init(uint16_t safety_param) { } } + if (envision_sdgm) { + static RxCheck envision_rx[] = { + GM_ASCM_INTERCEPT_RX_CHECKS + {.msg = {{0xBE, 0, 3, 10U, .ignore_checksum = true, .ignore_counter = true, .ignore_quality_flag = true}, {0}, {0}}}, + GM_ASCM_INTERCEPT_C9_CHECK + }; + SET_RX_CHECKS(envision_rx, ret); + } + if (gm_camera_gateway && !gm_camera_pedal_long) { static const CanMsg GM_GATEWAY_PEDAL_STOCK_TX[] = { {0x180, 0, 4, .check_relay = true}, {0x370, 0, 6, .check_relay = true}, diff --git a/opendbc_repo/opendbc/safety/modes/gm_aol.h b/opendbc_repo/opendbc/safety/modes/gm_aol.h index c31b10ed48..8403371af7 100644 --- a/opendbc_repo/opendbc/safety/modes/gm_aol.h +++ b/opendbc_repo/opendbc/safety/modes/gm_aol.h @@ -128,6 +128,7 @@ static bool gm_aol_profile_word(uint16_t word) { case 0x205U: case 0x605U: case 0xA05U: case 0xE05U: case 16U: case 0xC160U: case 0xC161U: case 0xC162U: case 0xC180U: case 0xC181U: case 0xC182U: case 0xC183U: case 0xC184U: case 0xC185U: case 0xC186U: case 0xC187U: + case 0xE900U: case 0x1001U: case 0x1401U: case 0x3001U: case 0x3401U: case 0x1005U: case 0x1405U: case 0x4004U: case 0xC004U: diff --git a/opendbc_repo/opendbc/safety/tests/test_gm_envision_sdgm.py b/opendbc_repo/opendbc/safety/tests/test_gm_envision_sdgm.py new file mode 100644 index 0000000000..32e9d5af90 --- /dev/null +++ b/opendbc_repo/opendbc/safety/tests/test_gm_envision_sdgm.py @@ -0,0 +1,135 @@ +"""Only the retrofit owner accepts the three-byte analog brake source.""" +import unittest +from opendbc.car.structs import CarParams +from opendbc.safety.tests.libsafety import libsafety_py + + +class TestGmEnvisionSdgm(unittest.TestCase): + def setUp(self): + self.safety = libsafety_py.libsafety + + def mode(self, word, experience=0): + self.safety.set_alternative_experience(experience) + self.assertEqual(self.safety.set_safety_hooks(CarParams.SafetyModel.gm, word), 0) + self.safety.init_tests() + self.safety.set_timer(1_000_000) + + def feed(self, word, length, experience=0, brake=0): + self.mode(word, experience) + for addr, dat in ((0x184, bytes(8)), (0x34A, bytes(5)), (0x1E1, bytes(7)), + (0x1C4, bytes(8)), (0xBE, bytes([0, brake, 0]) + bytes(max(0, length - 3))), + (0xC9, bytes(8))): + self.safety.safety_rx_hook(libsafety_py.make_CANPacket(addr, 0, dat)) + self.safety.safety_tick() + return self.safety.safety_config_valid() + + def test_new_length_does_not_change_existing_owners(self): + for experience in (0, 32): + self.assertTrue(self.feed(0xE900, 3, experience)) + for length in (6, 7, 8): + self.assertFalse(self.feed(0xE900, length, experience)) + for word in (0x1001, 0x3001): + self.assertTrue(self.feed(word, length, experience)) + for word in (0x1001, 0x3001): + self.assertFalse(self.feed(word, 3, experience)) + + def test_brake_staleness_and_longitudinal_rejection(self): + self.assertTrue(self.feed(0xE900, 3, brake=10)) + self.assertTrue(self.safety.get_brake_pressed_prev()) + self.safety.set_timer(3_000_000) + self.safety.safety_tick() + self.assertFalse(self.safety.safety_config_valid()) + self.safety.set_controls_allowed(True) + for addr, size in ((0x2CB, 8), (0x315, 5), (0x200, 6)): + self.assertFalse(self.safety.safety_tx_hook(libsafety_py.make_CANPacket(addr, 0, bytes(size)))) + + +class TestGmEnvisionAuthority(unittest.TestCase): + def setUp(self): + from opendbc.can import CANPacker + self.safety = libsafety_py.libsafety + self.packer = CANPacker('gm_global_a_powertrain_envision') + + def tearDown(self): + self.safety.set_alternative_experience(0) + + def reset(self, alternative=32): + self.safety.set_alternative_experience(alternative) + self.assertEqual(self.safety.set_safety_hooks(CarParams.SafetyModel.gm, 0xE900), 0) + self.safety.init_tests() + self.safety.set_timer(1_000_000) + self.safety.set_aol_test_heartbeat(True) + + @staticmethod + def packet(frame): + return libsafety_py.make_CANPacket(frame[0], frame[2], frame[1]) + + def feed(self, *, main=True, brake=False, active=False): + for name, values in ( + ('PSCMStatus', {}), ('EBCMWheelSpdRear', {}), ('ASCMSteeringButton', {'ACCButtons': 1}), + ('AcceleratorPedal2', {'CruiseState': int(active)}), + ('ECMAcceleratorPos', {'BrakePedalPos': 10 if brake else 0}), + ('ECMEngineStatus', {'CruiseMainOn': int(main)}), + ): + self.assertTrue(self.safety.safety_rx_hook(self.packet(self.packer.make_can_msg(name, 0, values)))) + self.safety.safety_tick() + self.assertTrue(self.safety.safety_config_valid()) + + def steer(self, torque): + from opendbc.car.gm import gmcan + return self.safety.safety_tx_hook(self.packet(gmcan.create_steering_control(self.packer, 0, torque, 0, True))) + + def test_main_brake_and_freshness_authority(self): + self.reset() + self.feed() + self.safety.aol_set_host_request(1) + self.assertEqual(self.safety.aol_get_permission_mask(), 1) + self.assertTrue(self.steer(1)) + self.feed(brake=True) + self.assertTrue(self.safety.get_brake_pressed_prev()) + self.assertFalse(self.safety.get_controls_allowed()) + self.safety.aol_set_host_request(1) + self.assertEqual(self.safety.aol_get_permission_mask(), 1) + self.feed(main=False) + self.safety.aol_set_host_request(1) + self.assertEqual(self.safety.aol_get_permission_mask(), 0) + self.assertFalse(self.steer(1)) + self.feed() + self.safety.aol_set_host_request(1) + self.assertTrue(self.steer(1)) + self.safety.set_timer(1_300_001) + self.safety.aol_set_host_request(1) + self.assertEqual(self.safety.aol_get_permission_mask(), 0) + self.assertFalse(self.steer(1)) + + def test_steering_rate_and_absolute_limit_preserved(self): + for torque in (11, -11, 301, -301): + self.reset() + self.feed() + self.safety.aol_set_host_request(1) + self.assertFalse(self.steer(torque), torque) + self.reset() + self.feed() + self.safety.aol_set_host_request(1) + self.assertTrue(self.steer(1)) + self.safety.set_aol_test_heartbeat(False) + self.assertFalse(self.steer(1)) + + def test_no_aol_without_exact_experience(self): + for alternative in (0, 4, 33, 34): + self.reset(alternative) + self.feed() + self.safety.aol_set_host_request(1) + self.assertEqual(self.safety.aol_get_permission_mask(), 0) + self.assertFalse(self.steer(1)) + + def test_forwarding_and_relay_protection(self): + self.reset() + for bus, addr, expected in ((0, 0x123, 2), (0, 0x184, -1), (2, 0x123, 0), + (2, 0x180, -1), (2, 0x315, 0), (1, 0x123, -1)): + self.assertEqual(self.safety.safety_fwd_hook(bus, addr), expected) + self.safety.safety_rx_hook(libsafety_py.make_CANPacket(0x184, 2, bytes(8))) + self.assertFalse(self.safety.get_relay_malfunction()) + self.safety.safety_rx_hook(libsafety_py.make_CANPacket(0x180, 0, bytes(4))) + self.assertTrue(self.safety.get_relay_malfunction()) + self.assertFalse(self.steer(1)) diff --git a/openpilot/selfdrive/pandad/pandad b/openpilot/selfdrive/pandad/pandad index 76cd96f966..bf42b44e91 100755 Binary files a/openpilot/selfdrive/pandad/pandad and b/openpilot/selfdrive/pandad/pandad differ diff --git a/openpilot/selfdrive/pandad/pandad.o b/openpilot/selfdrive/pandad/pandad.o index fe39373c6e..736e12d6b2 100644 Binary files a/openpilot/selfdrive/pandad/pandad.o and b/openpilot/selfdrive/pandad/pandad.o differ diff --git a/openpilot/starpilot/car/gm/aol_policy.h b/openpilot/starpilot/car/gm/aol_policy.h index c8566b1093..f612b1f109 100644 --- a/openpilot/starpilot/car/gm/aol_policy.h +++ b/openpilot/starpilot/car/gm/aol_policy.h @@ -50,6 +50,7 @@ inline bool gm_aol_param(uint16_t param) { case 0x4004U: case 0xC004U: case 0x4084U: case 0xC084U: case 0x4007U: case 16U: case 0xC160U: case 0xC161U: case 0xC162U: case 0xC163U: case 0xC180U: case 0xC181U: case 0xC182U: case 0xC183U: case 0xC184U: case 0xC185U: case 0xC186U: case 0xC187U: case 0xC170U: + case 0xE900U: case 0x1001U: case 0x1401U: case 0x3001U: case 0x3401U: case 0x1003U: case 0x1403U: case 0x1005U: case 0x1405U: case 0x5007U: case 0x5407U: diff --git a/panda/board/obj/gitversion.h b/panda/board/obj/gitversion.h index f0b0ac0740..7462773aae 100644 --- a/panda/board/obj/gitversion.h +++ b/panda/board/obj/gitversion.h @@ -1,4 +1,4 @@ #pragma once extern const uint8_t gitversion[29]; -const uint8_t gitversion[29] = "DEV-5a62d763-Pf38f504f-DEBUG"; +const uint8_t gitversion[29] = "DEV-afe52f45-Pf38f504f-DEBUG"; diff --git a/panda/board/obj/panda.bin.signed b/panda/board/obj/panda.bin.signed index 77712db4a6..28a554e21c 100644 Binary files a/panda/board/obj/panda.bin.signed and b/panda/board/obj/panda.bin.signed differ diff --git a/panda/board/obj/panda_can_ignition_only.bin.signed b/panda/board/obj/panda_can_ignition_only.bin.signed index 33603b3194..34a0839322 100644 Binary files a/panda/board/obj/panda_can_ignition_only.bin.signed and b/panda/board/obj/panda_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_h7.bin.signed b/panda/board/obj/panda_h7.bin.signed index 186a449afd..b702ab1b45 100644 Binary files a/panda/board/obj/panda_h7.bin.signed and b/panda/board/obj/panda_h7.bin.signed differ diff --git a/panda/board/obj/panda_h7_can_ignition_only.bin.signed b/panda/board/obj/panda_h7_can_ignition_only.bin.signed index bb0a3918bd..bb5d795627 100644 Binary files a/panda/board/obj/panda_h7_can_ignition_only.bin.signed and b/panda/board/obj/panda_h7_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_h7_hkg_remote.bin.signed b/panda/board/obj/panda_h7_hkg_remote.bin.signed index 4c93748482..dc0f2e590d 100644 Binary files a/panda/board/obj/panda_h7_hkg_remote.bin.signed and b/panda/board/obj/panda_h7_hkg_remote.bin.signed differ diff --git a/panda/board/obj/panda_h7_hkg_remote_can_ignition_only.bin.signed b/panda/board/obj/panda_h7_hkg_remote_can_ignition_only.bin.signed index 9d4fca4833..ea81445b56 100644 Binary files a/panda/board/obj/panda_h7_hkg_remote_can_ignition_only.bin.signed and b/panda/board/obj/panda_h7_hkg_remote_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_h7_remote.bin.signed b/panda/board/obj/panda_h7_remote.bin.signed index 08c03cef93..fc760a501d 100644 Binary files a/panda/board/obj/panda_h7_remote.bin.signed and b/panda/board/obj/panda_h7_remote.bin.signed differ diff --git a/panda/board/obj/panda_h7_remote_can_ignition_only.bin.signed b/panda/board/obj/panda_h7_remote_can_ignition_only.bin.signed index 6a4551e989..ca8f7a7595 100644 Binary files a/panda/board/obj/panda_h7_remote_can_ignition_only.bin.signed and b/panda/board/obj/panda_h7_remote_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_h7_tesla_wake.bin.signed b/panda/board/obj/panda_h7_tesla_wake.bin.signed index 5479ebb65b..c33de98aeb 100644 Binary files a/panda/board/obj/panda_h7_tesla_wake.bin.signed and b/panda/board/obj/panda_h7_tesla_wake.bin.signed differ diff --git a/panda/board/obj/panda_h7_tesla_wake_can_ignition_only.bin.signed b/panda/board/obj/panda_h7_tesla_wake_can_ignition_only.bin.signed index 6dacfc6d00..bca25691ff 100644 Binary files a/panda/board/obj/panda_h7_tesla_wake_can_ignition_only.bin.signed and b/panda/board/obj/panda_h7_tesla_wake_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_hkg_remote.bin.signed b/panda/board/obj/panda_hkg_remote.bin.signed index 8c6840b75f..c4455dd2eb 100644 Binary files a/panda/board/obj/panda_hkg_remote.bin.signed and b/panda/board/obj/panda_hkg_remote.bin.signed differ diff --git a/panda/board/obj/panda_hkg_remote_can_ignition_only.bin.signed b/panda/board/obj/panda_hkg_remote_can_ignition_only.bin.signed index c0854bc32a..3ea92fcc7c 100644 Binary files a/panda/board/obj/panda_hkg_remote_can_ignition_only.bin.signed and b/panda/board/obj/panda_hkg_remote_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_remote.bin.signed b/panda/board/obj/panda_remote.bin.signed index c379f778e9..3e6def6ba5 100644 Binary files a/panda/board/obj/panda_remote.bin.signed and b/panda/board/obj/panda_remote.bin.signed differ diff --git a/panda/board/obj/panda_remote_can_ignition_only.bin.signed b/panda/board/obj/panda_remote_can_ignition_only.bin.signed index 84c0a6afa5..48ffc2b1b1 100644 Binary files a/panda/board/obj/panda_remote_can_ignition_only.bin.signed and b/panda/board/obj/panda_remote_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/panda_tesla_wake.bin.signed b/panda/board/obj/panda_tesla_wake.bin.signed index 725adc7b9c..cca1101d1d 100644 Binary files a/panda/board/obj/panda_tesla_wake.bin.signed and b/panda/board/obj/panda_tesla_wake.bin.signed differ diff --git a/panda/board/obj/panda_tesla_wake_can_ignition_only.bin.signed b/panda/board/obj/panda_tesla_wake_can_ignition_only.bin.signed index 6b66a5c315..6f310e77fa 100644 Binary files a/panda/board/obj/panda_tesla_wake_can_ignition_only.bin.signed and b/panda/board/obj/panda_tesla_wake_can_ignition_only.bin.signed differ diff --git a/panda/board/obj/version b/panda/board/obj/version index 146478245a..7cc8c76524 100644 --- a/panda/board/obj/version +++ b/panda/board/obj/version @@ -1 +1 @@ -DEV-5a62d763-Pf38f504f-DEBUG \ No newline at end of file +DEV-afe52f45-Pf38f504f-DEBUG \ No newline at end of file diff --git a/prebuilt.json b/prebuilt.json index 6ef9aa4843..81a49c6fb4 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "8b00e138676ce76a988b4f5e17578c737f080500d4e99a42b3547ce48b40b4bf", "schema_version": 1} +{"protected_inventory_sha256": "f1418e72375f9ffc4b385e362aa3c01fcc62cd23053974db524bbe86fe43bbbc", "schema_version": 1}