9
9
10
10
MAX_RATE_UP = 4
11
11
MAX_RATE_DOWN = 10
12
- MAX_STEER = 250
12
+ MAX_STEER = 300
13
13
MAX_RT_DELTA = 75
14
14
RT_INTERVAL = 250000
15
15
19
19
MSG_ESP_19 = 0xB2 # RX from ABS, for wheel speeds
20
20
MSG_EPS_01 = 0x9F # RX from EPS, for driver steering torque
21
21
MSG_ESP_05 = 0x106 # RX from ABS, for brake light state
22
+ MSG_TSK_06 = 0x120 # RX from ECU, for ACC status from drivetrain coordinator
22
23
MSG_MOTOR_20 = 0x121 # RX from ECU, for driver throttle input
23
- MSG_ACC_06 = 0x122 # RX from ACC radar, for status and engagement
24
24
MSG_HCA_01 = 0x126 # TX by OP, Heading Control Assist steering torque
25
25
MSG_GRA_ACC_01 = 0x12B # TX by OP, ACC control buttons for cancel/resume
26
26
MSG_LDW_02 = 0x397 # TX by OP, Lane line recognition and text alerts
@@ -48,10 +48,10 @@ def volkswagen_mqb_crc(msg, addr, len_msg):
48
48
magic_pad = b'\xF5 \xF5 \xF5 \xF5 \xF5 \xF5 \xF5 \xF5 \xF5 \xF5 \xF5 \xF5 \xF5 \xF5 \xF5 \xF5 ' [counter ]
49
49
elif addr == MSG_ESP_05 :
50
50
magic_pad = b'\x07 \x07 \x07 \x07 \x07 \x07 \x07 \x07 \x07 \x07 \x07 \x07 \x07 \x07 \x07 \x07 ' [counter ]
51
+ elif addr == MSG_TSK_06 :
52
+ magic_pad = b'\xC4 \xE2 \x4F \xE4 \xF8 \x2F \x56 \x81 \x9F \xE5 \x83 \x44 \x05 \x3F \x97 \xDF ' [counter ]
51
53
elif addr == MSG_MOTOR_20 :
52
54
magic_pad = b'\xE9 \x65 \xAE \x6B \x7B \x35 \xE5 \x5F \x4E \xC7 \x86 \xA2 \xBB \xDD \xEB \xB4 ' [counter ]
53
- elif addr == MSG_ACC_06 :
54
- magic_pad = b'\x37 \x7D \xF3 \xA9 \x18 \x46 \x6D \x4D \x3D \x71 \x92 \x9C \xE5 \x32 \x10 \xB9 ' [counter ]
55
55
elif addr == MSG_HCA_01 :
56
56
magic_pad = b'\xDA \xDA \xDA \xDA \xDA \xDA \xDA \xDA \xDA \xDA \xDA \xDA \xDA \xDA \xDA \xDA ' [counter ]
57
57
elif addr == MSG_GRA_ACC_01 :
@@ -63,8 +63,8 @@ def volkswagen_mqb_crc(msg, addr, len_msg):
63
63
class TestVolkswagenMqbSafety (unittest .TestCase ):
64
64
cnt_eps_01 = 0
65
65
cnt_esp_05 = 0
66
+ cnt_tsk_06 = 0
66
67
cnt_motor_20 = 0
67
- cnt_acc_06 = 0
68
68
cnt_hca_01 = 0
69
69
cnt_gra_acc_01 = 0
70
70
@@ -120,12 +120,12 @@ def _hca_01_msg(self, torque):
120
120
return to_send
121
121
122
122
# ACC engagement status
123
- def _acc_06_msg (self , status ):
124
- to_send = make_msg (0 , MSG_ACC_06 )
125
- to_send [0 ].RDHR = (status & 0x7 ) << 28
126
- to_send [0 ].RDLR |= (self .cnt_acc_06 % 16 ) << 8
127
- to_send [0 ].RDLR |= volkswagen_mqb_crc (to_send [0 ], MSG_ACC_06 , 8 )
128
- self .__class__ .cnt_acc_06 += 1
123
+ def _tsk_06_msg (self , status ):
124
+ to_send = make_msg (0 , MSG_TSK_06 )
125
+ to_send [0 ].RDLR = (status & 0x7 ) << 24
126
+ to_send [0 ].RDLR |= (self .cnt_tsk_06 % 16 ) << 8
127
+ to_send [0 ].RDLR |= volkswagen_mqb_crc (to_send [0 ], MSG_TSK_06 , 8 )
128
+ self .__class__ .cnt_tsk_06 += 1
129
129
return to_send
130
130
131
131
# Driver throttle input
@@ -162,12 +162,12 @@ def test_default_controls_not_allowed(self):
162
162
163
163
def test_enable_control_allowed_from_cruise (self ):
164
164
self .safety .set_controls_allowed (0 )
165
- self .safety .safety_rx_hook (self ._acc_06_msg (3 ))
165
+ self .safety .safety_rx_hook (self ._tsk_06_msg (3 ))
166
166
self .assertTrue (self .safety .get_controls_allowed ())
167
167
168
168
def test_disable_control_allowed_from_cruise (self ):
169
169
self .safety .set_controls_allowed (1 )
170
- self .safety .safety_rx_hook (self ._acc_06_msg (1 ))
170
+ self .safety .safety_rx_hook (self ._tsk_06_msg (1 ))
171
171
self .assertFalse (self .safety .get_controls_allowed ())
172
172
173
173
def test_sample_speed (self ):
@@ -351,16 +351,16 @@ def test_rx_hook(self):
351
351
# TODO: Would be ideal to check ESP_19 as well, but it has no checksum
352
352
# or counter, and I'm not sure if we can easily validate Panda's simple
353
353
# temporal reception-rate check here.
354
- for msg in [MSG_EPS_01 , MSG_ESP_05 , MSG_MOTOR_20 , MSG_ACC_06 ]:
354
+ for msg in [MSG_EPS_01 , MSG_ESP_05 , MSG_TSK_06 , MSG_MOTOR_20 ]:
355
355
self .safety .set_controls_allowed (1 )
356
356
if msg == MSG_EPS_01 :
357
357
to_push = self ._eps_01_msg (0 )
358
358
if msg == MSG_ESP_05 :
359
359
to_push = self ._esp_05_msg (False )
360
+ if msg == MSG_TSK_06 :
361
+ to_push = self ._tsk_06_msg (3 )
360
362
if msg == MSG_MOTOR_20 :
361
363
to_push = self ._motor_20_msg (0 )
362
- if msg == MSG_ACC_06 :
363
- to_push = self ._acc_06_msg (3 )
364
364
self .assertTrue (self .safety .safety_rx_hook (to_push ))
365
365
to_push [0 ].RDHR ^= 0xFF
366
366
self .assertFalse (self .safety .safety_rx_hook (to_push ))
@@ -371,28 +371,28 @@ def test_rx_hook(self):
371
371
for i in range (MAX_WRONG_COUNTERS + 1 ):
372
372
self .__class__ .cnt_eps_01 += 1
373
373
self .__class__ .cnt_esp_05 += 1
374
+ self .__class__ .cnt_tsk_06 += 1
374
375
self .__class__ .cnt_motor_20 += 1
375
- self .__class__ .cnt_acc_06 += 1
376
376
if i < MAX_WRONG_COUNTERS :
377
377
self .safety .set_controls_allowed (1 )
378
378
self .safety .safety_rx_hook (self ._eps_01_msg (0 ))
379
379
self .safety .safety_rx_hook (self ._esp_05_msg (False ))
380
+ self .safety .safety_rx_hook (self ._tsk_06_msg (3 ))
380
381
self .safety .safety_rx_hook (self ._motor_20_msg (0 ))
381
- self .safety .safety_rx_hook (self ._acc_06_msg (3 ))
382
382
else :
383
383
self .assertFalse (self .safety .safety_rx_hook (self ._eps_01_msg (0 )))
384
384
self .assertFalse (self .safety .safety_rx_hook (self ._esp_05_msg (False )))
385
+ self .assertFalse (self .safety .safety_rx_hook (self ._tsk_06_msg (3 )))
385
386
self .assertFalse (self .safety .safety_rx_hook (self ._motor_20_msg (0 )))
386
- self .assertFalse (self .safety .safety_rx_hook (self ._acc_06_msg (3 )))
387
387
self .assertFalse (self .safety .get_controls_allowed ())
388
388
389
389
# restore counters for future tests with a couple of good messages
390
390
for i in range (2 ):
391
391
self .safety .set_controls_allowed (1 )
392
392
self .safety .safety_rx_hook (self ._eps_01_msg (0 ))
393
393
self .safety .safety_rx_hook (self ._esp_05_msg (False ))
394
+ self .safety .safety_rx_hook (self ._tsk_06_msg (3 ))
394
395
self .safety .safety_rx_hook (self ._motor_20_msg (0 ))
395
- self .safety .safety_rx_hook (self ._acc_06_msg (3 ))
396
396
self .assertTrue (self .safety .get_controls_allowed ())
397
397
398
398
def test_fwd_hook (self ):
0 commit comments