diff --git a/board/safety/safety_gm.h b/board/safety/safety_gm.h index dc4ba0e28d..3bc6384472 100644 --- a/board/safety/safety_gm.h +++ b/board/safety/safety_gm.h @@ -61,6 +61,7 @@ AddrCheckStruct gm_addr_checks[] = { {190, 0, 7, .expected_timestep = 100000U}, // Bolt EUV {190, 0, 8, .expected_timestep = 100000U}}}, // Escalade {.msg = {{452, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, + {.msg = {{201, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, }; #define GM_RX_CHECK_LEN (sizeof(gm_addr_checks) / sizeof(gm_addr_checks[0])) addr_checks gm_rx_checks = {gm_addr_checks, GM_RX_CHECK_LEN}; @@ -119,12 +120,16 @@ static int gm_rx_hook(CANPacket_t *to_push) { cruise_button_prev = button; } - if (addr == 190) { - // Reference for signal and threshold: - // https://github.com/commaai/openpilot/blob/master/selfdrive/car/gm/carstate.py + // Reference for brake pressed signals: + // https://github.com/commaai/openpilot/blob/master/selfdrive/car/gm/carstate.py + if ((addr == 190) && (gm_hw == GM_ASCM)) { brake_pressed = GET_BYTE(to_push, 1) >= 8U; } + if ((addr == 201) && (gm_hw == GM_CAM)) { + brake_pressed = GET_BIT(to_push, 40U) != 0U; + } + if (addr == 452) { gas_pressed = GET_BYTE(to_push, 5) != 0U; diff --git a/tests/safety/test_gm.py b/tests/safety/test_gm.py index e8e5430cab..696124319b 100755 --- a/tests/safety/test_gm.py +++ b/tests/safety/test_gm.py @@ -15,9 +15,10 @@ class Buttons: class GmLongitudinalBase(common.PandaSafetyTest): + # pylint: disable=no-member,abstract-method + PCM_CRUISE = False # openpilot can control the PCM state if longitudinal - # pylint: disable=no-member,abstract-method def test_set_resume_buttons(self): """ SET and RESUME enter controls allowed on their falling edge. @@ -176,11 +177,26 @@ def setUp(self): self.safety.init_tests() -class TestGmCameraSafety(TestGmSafetyBase): +class TestGmCameraSafetyBase(TestGmSafetyBase): + + FWD_BUS_LOOKUP = {0: 2, 2: 0} + + @classmethod + def setUpClass(cls): + if cls.__name__ == "TestGmCameraSafetyBase": + cls.packer = None + cls.safety = None + raise unittest.SkipTest + + def _user_brake_msg(self, brake): + values = {"BrakePressed": brake} + return self.packer.make_can_msg_panda("ECMEngineStatus", 0, values) + + +class TestGmCameraSafety(TestGmCameraSafetyBase): TX_MSGS = [[384, 0], # pt bus [388, 2]] # camera bus FWD_BLACKLISTED_ADDRS = {2: [384], 0: [388]} # block LKAS message and PSCMStatus - FWD_BUS_LOOKUP = {0: 2, 2: 0} BUTTONS_BUS = 2 # tx only def setUp(self): @@ -212,11 +228,10 @@ def test_gas_safety_check(self): pass -class TestGmCameraLongitudinalSafety(GmLongitudinalBase, TestGmSafetyBase): +class TestGmCameraLongitudinalSafety(GmLongitudinalBase, TestGmCameraSafetyBase): TX_MSGS = [[384, 0], [789, 0], [715, 0], [880, 0], # pt bus [388, 2]] # camera bus FWD_BLACKLISTED_ADDRS = {2: [384, 715, 880, 789], 0: [388]} # block LKAS, ACC messages and PSCMStatus - FWD_BUS_LOOKUP = {0: 2, 2: 0} BUTTONS_BUS = 0 # rx only MAX_GAS = 3400