forked from commaai/panda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6_safety.py
33 lines (27 loc) · 1.02 KB
/
6_safety.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)