mirror of https://github.com/commaai/panda.git
Toyota: add AEB message TX checks (#820)
* Toyota: add AEB message TX checks * misra
This commit is contained in:
parent
79f5e6fe86
commit
f5857bc8fd
|
@ -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) {
|
||||
|
|
|
@ -74,12 +74,23 @@ class TestToyotaSafety(common.PandaSafetyTest, common.InterceptorSafetyTest,
|
|||
# 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))
|
||||
|
|
Loading…
Reference in New Issue