[$250 bounty] Move CAN ignition hooks and add test
CAN ignition lives in board/drivers/can_common.h. This is the last car-specific code in panda and should be moved here.
It should also be possible to fully validate these signals in CI. Assert that the hook doesn't unintentionally trip on all the other cars, etc.
with proper rx checks (counter, checksum, etc.) to reduce chances of overlap between cars
with proper rx checks (counter, checksum, etc.) to reduce chances of overlap between cars
Let's do this as a separate issue once this is in.
@ccdunder want to tackle this one?
@sshane I humbly propose https://github.com/commaai/opendbc/pull/2131
Lemme know what you think!
I've been experimenting with adding CAN ignition coverage to test_models.py
In the experiment, we check every rx to ensure that only [gm|mazda|rivian|tesla] see CAN ignition. I.e.:
diff --git a/selfdrive/car/tests/test_models.py b/selfdrive/car/tests/test_models.py
index 53f2bb586..48b33b42b 100644
--- a/selfdrive/car/tests/test_models.py
+++ b/selfdrive/car/tests/test_models.py
@@ -243,6 +243,11 @@ class TestCarModelBase(unittest.TestCase):
if self.safety.safety_rx_hook(to_send) != 1:
failed_addrs[hex(msg.address)] += 1
+ if self.CP.brand in ("gm", "mazda", "rivian", "tesla"):
+ self.assertTrue(self.safety.get_ignition_can())
+ else:
+ self.assertFalse(self.safety.get_ignition_can())
+
# ensure all msgs defined in the addr checks are valid
self.safety.safety_tick_current_safety_config()
if t > 1e6:
But there are two problems with this:
assertFalseon every rx blows up the test run time from 6 mins to 15 mins- Not every single message from the [gm|mazda|rivian|tesla] logs have ignition_can == True (see CI failure)
@sshane do you have a preferred way to deal with these problems? Here are some options:
- (a) find different logs for [gm|mazda|rivian|tesla] where every rx has CAN-ignition
- (b) instrument opendbc with a counter or a latch that triggers whenever CAN-ignition is detected, check this after all rxs are sent instead of after each individual rx
PRs in progress:
- https://github.com/commaai/opendbc/pull/2131
- https://github.com/commaai/panda/pull/2195
- https://github.com/commaai/openpilot/pull/35082 (patches in the previous PRs so that we can exercise the newly-exposed can ignition state)
can I work on this ?