diff --git a/panda/board/safety.h b/panda/board/safety.h index a2e803ea3..24ff77907 100644 --- a/panda/board/safety.h +++ b/panda/board/safety.h @@ -275,7 +275,7 @@ void generic_rx_checks(bool stock_ecu_detected) { regen_braking_prev = regen_braking; // check if stock ECU is on bus broken by car harness - if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && stock_ecu_detected) { + if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && stock_ecu_detected && !gm_skip_relay_check) { relay_malfunction_set(); } } diff --git a/panda/board/safety/safety_gm.h b/panda/board/safety/safety_gm.h index 13cfc023c..89a9a7f30 100644 --- a/panda/board/safety/safety_gm.h +++ b/panda/board/safety/safety_gm.h @@ -98,6 +98,7 @@ bool gm_pcm_cruise = false; bool gm_cc_long = false; bool gm_has_acc = true; bool gm_pedal_long = false; +bool gm_skip_relay_check = false; bool gm_force_ascm = false; static void handle_gm_wheel_buttons(const CANPacket_t *to_push) { @@ -325,6 +326,7 @@ static safety_config gm_init(uint16_t param) { gm_cc_long = GET_FLAG(param, GM_PARAM_CC_LONG); gm_cam_long = GET_FLAG(param, GM_PARAM_HW_CAM_LONG) && !gm_cc_long; gm_pcm_cruise = ((gm_hw == GM_CAM) && (!gm_cam_long || gm_cc_long) && !gm_force_ascm && !gm_pedal_long) || (gm_hw == GM_SDGM); + gm_skip_relay_check = GET_FLAG(param, GM_PARAM_NO_CAMERA); gm_has_acc = !GET_FLAG(param, GM_PARAM_NO_ACC); enable_gas_interceptor = GET_FLAG(param, GM_PARAM_PEDAL_INTERCEPTOR); diff --git a/panda/python/__init__.py b/panda/python/__init__.py index 727069340..182754468 100644 --- a/panda/python/__init__.py +++ b/panda/python/__init__.py @@ -235,6 +235,7 @@ class Panda: FLAG_GM_HW_SDGM = 4 FLAG_GM_CC_LONG = 8 FLAG_GM_HW_ASCM_LONG = 16 + FLAG_GM_NO_CAMERA = 32 FLAG_GM_NO_ACC = 64 FLAG_GM_PEDAL_LONG = 128 # TODO: This can be inferred FLAG_GM_GAS_INTERCEPTOR = 256 diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py index ad8643640..5a5c986e7 100644 --- a/selfdrive/car/gm/carstate.py +++ b/selfdrive/car/gm/carstate.py @@ -55,7 +55,7 @@ class CarState(CarStateBase): self.loopback_lka_steering_cmd_updated = len(loopback_cp.vl_all["ASCMLKASteeringCmd"]["RollingCounter"]) > 0 if self.loopback_lka_steering_cmd_updated: self.loopback_lka_steering_cmd_ts_nanos = loopback_cp.ts_nanos["ASCMLKASteeringCmd"]["RollingCounter"] - if self.CP.networkLocation == NetworkLocation.fwdCamera: + if self.CP.networkLocation == NetworkLocation.fwdCamera and not self.CP.flags & GMFlags.NO_CAMERA.value: self.pt_lka_steering_cmd_counter = pt_cp.vl["ASCMLKASteeringCmd"]["RollingCounter"] self.cam_lka_steering_cmd_counter = cam_cp.vl["ASCMLKASteeringCmd"]["RollingCounter"] @@ -179,7 +179,7 @@ class CarState(CarStateBase): @staticmethod def get_cam_can_parser(CP): messages = [] - if CP.networkLocation == NetworkLocation.fwdCamera: + if CP.networkLocation == NetworkLocation.fwdCamera and not CP.flags & GMFlags.NO_CAMERA.value: messages += [ ("ASCMLKASteeringCmd", 10), ] diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py old mode 100755 new mode 100644 index 8527d6185..f21a0811c --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -22,6 +22,8 @@ BUTTONS_DICT = {CruiseButtons.RES_ACCEL: ButtonType.accelCruise, CruiseButtons.D FrogPilotButtonType = custom.FrogPilotCarState.ButtonEvent.Type PEDAL_MSG = 0x201 +CAM_MSG = 0x320 # AEBCmd + # TODO: Is this always linked to camera presence? ACCELERATOR_POS_MSG = 0xbe NON_LINEAR_TORQUE_PARAMS = { @@ -299,6 +301,11 @@ class CarInterface(CarInterfaceBase): if ACCELERATOR_POS_MSG not in fingerprint[CanBus.POWERTRAIN]: ret.flags |= GMFlags.NO_ACCELERATOR_POS_MSG.value + # Exception for flashed cars, or cars whose camera was removed + if (ret.networkLocation == NetworkLocation.fwdCamera or candidate in CC_ONLY_CAR) and CAM_MSG not in fingerprint[CanBus.CAMERA] and not candidate in SDGM_CAR: + ret.flags |= GMFlags.NO_CAMERA.value + ret.safetyConfigs[0].safetyParam |= Panda.FLAG_GM_NO_CAMERA + if ACCELERATOR_POS_MSG not in fingerprint[CanBus.POWERTRAIN]: ret.flags |= GMFlags.NO_ACCELERATOR_POS_MSG.value diff --git a/selfdrive/car/gm/values.py b/selfdrive/car/gm/values.py index b6703e990..d97284d8d 100644 --- a/selfdrive/car/gm/values.py +++ b/selfdrive/car/gm/values.py @@ -1,5 +1,5 @@ from dataclasses import dataclass, field -from enum import Enum +from enum import Enum, IntFlag from cereal import car from openpilot.common.params import Params @@ -266,6 +266,7 @@ class CanBus: class GMFlags(IntFlag): PEDAL_LONG = 1 CC_LONG = 2 + NO_CAMERA = 4 NO_ACCELERATOR_POS_MSG = 8 # In a Data Module, an identifier is a string used to recognize an object,