diff --git a/board/safety/safety_toyota.h b/board/safety/safety_toyota.h index f3d5eff7ee..648d10d768 100644 --- a/board/safety/safety_toyota.h +++ b/board/safety/safety_toyota.h @@ -172,6 +172,15 @@ static int toyota_tx_hook(CANPacket_t *to_send) { } } + // AEB: block all actuation. only used when DSU is unplugged + if (addr == 0x283) { + // only allow the checksum, which is the last byte + bool block = (GET_BYTES_04(to_send) != 0U) || (GET_BYTE(to_send, 4) != 0U) || (GET_BYTE(to_send, 5) != 0U); + if (block) { + tx = 0; + } + } + // LTA steering check // only sent to prevent dash errors, no actuation is accepted if (addr == 0x191) { diff --git a/tests/safety/test_toyota.py b/tests/safety/test_toyota.py index 11c0a5fb63..ab9cb22896 100755 --- a/tests/safety/test_toyota.py +++ b/tests/safety/test_toyota.py @@ -74,12 +74,23 @@ def _pcm_status_msg(self, enable): # Toyota gas gains are the same def _interceptor_msg(self, gas, addr): to_send = make_msg(0, addr, 6) - to_send[0].data[0] = (gas & 0xFF00) >> 8 + to_send[0].data[0] = (gas & 0xFF00) >> 8 to_send[0].data[1] = gas & 0xFF to_send[0].data[2] = (gas & 0xFF00) >> 8 to_send[0].data[3] = gas & 0xFF return to_send + def test_block_aeb(self): + for controls_allowed in (True, False): + for bad in (True, False): + for _ in range(10): + self.safety.set_controls_allowed(controls_allowed) + dat = [random.randint(1, 255) for _ in range(7)] + if not bad: + dat = [0]*6 + dat[-1:] + msg = common.package_can_msg([0x283, 0, bytes(dat), 0]) + self.assertEqual(not bad, self._tx(msg)) + def test_accel_actuation_limits(self): limits = ((MIN_ACCEL, MAX_ACCEL, UNSAFE_MODE.DEFAULT), (MIN_ACCEL, MAX_ACCEL, UNSAFE_MODE.RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX))