cleanup CAN definitions (#1170)

This commit is contained in:
Adeeb Shihadeh
2022-11-29 15:56:43 -08:00
committed by GitHub
parent 702e5281d8
commit 80dac4cd94
11 changed files with 70 additions and 51 deletions

View File

@@ -31,22 +31,6 @@ def test_can_loopback(p):
assert 0x1aa == sr[0][0] == lb[0][0]
assert b"message" == sr[0][2] == lb[0][2]
@test_all_pandas
@panda_connect_and_init
def test_safety_nooutput(p):
p.set_safety_mode(Panda.SAFETY_SILENT)
p.set_can_loopback(True)
# send a message on bus 0
p.can_send(0x1aa, b"message", 0)
# confirm receive nothing
time.sleep(0.05)
r = p.can_recv()
# bus 192 is messages blocked by TX safety hook on bus 0
assert len([x for x in r if x[3] != 192]) == 0
assert len([x for x in r if x[3] == 192]) == 1
@test_all_pandas
@panda_connect_and_init
def test_reliability(p):

33
tests/hitl/6_safety.py Normal file
View File

@@ -0,0 +1,33 @@
import time
from nose.tools import assert_equal
from panda import Panda
from .helpers import test_all_pandas, panda_connect_and_init
@test_all_pandas
@panda_connect_and_init
def test_safety_nooutput(p):
p.set_safety_mode(Panda.SAFETY_SILENT)
p.set_can_loopback(True)
# send a message on bus 0
p.can_send(0x1aa, b"message", 0)
# confirm receive nothing
time.sleep(0.05)
r = p.can_recv()
# bus 192 is messages blocked by TX safety hook on bus 0
assert len([x for x in r if x[3] != 192]) == 0
assert len([x for x in r if x[3] == 192]) == 1
@test_all_pandas
@panda_connect_and_init
def test_canfd_safety_modes(p):
# works on all pandas
p.set_safety_mode(Panda.SAFETY_TOYOTA)
assert_equal(p.health()['safety_mode'], Panda.SAFETY_TOYOTA)
# shouldn't be able to set a CAN-FD safety mode on non CAN-FD panda
p.set_safety_mode(Panda.SAFETY_HYUNDAI_CANFD)
expected_mode = Panda.SAFETY_HYUNDAI_CANFD if p.get_type() in Panda.H7_DEVICES else Panda.SAFETY_SILENT
assert_equal(p.health()['safety_mode'], expected_mode)