9
9
10
10
MAX_BRAKE = 255
11
11
12
- INTERCEPTOR_THRESHOLD = 344
13
-
14
12
class Btn :
15
13
CANCEL = 2
16
14
SET = 3
@@ -20,14 +18,6 @@ class Btn:
20
18
HONDA_BG_HW = 1
21
19
HONDA_BH_HW = 2
22
20
23
- # Honda gas gains are the different
24
- def honda_interceptor_msg (gas , addr ):
25
- to_send = make_msg (0 , addr , 6 )
26
- gas2 = gas * 2
27
- to_send [0 ].RDLR = ((gas & 0xff ) << 8 ) | ((gas & 0xff00 ) >> 8 ) | \
28
- ((gas2 & 0xff ) << 24 ) | ((gas2 & 0xff00 ) << 8 )
29
- return to_send
30
-
31
21
32
22
class TestHondaSafety (common .PandaSafetyTest ):
33
23
cnt_speed = 0
@@ -102,43 +92,6 @@ def test_disengage_on_brake(self):
102
92
self ._rx (self ._brake_msg (1 ))
103
93
self .assertFalse (self .safety .get_controls_allowed ())
104
94
105
- def test_prev_gas_interceptor (self ):
106
- self ._rx (honda_interceptor_msg (0x0 , 0x201 ))
107
- self .assertFalse (self .safety .get_gas_interceptor_prev ())
108
- self ._rx (honda_interceptor_msg (0x1000 , 0x201 ))
109
- self .assertTrue (self .safety .get_gas_interceptor_prev ())
110
- self ._rx (honda_interceptor_msg (0x0 , 0x201 ))
111
- self .safety .set_gas_interceptor_detected (False )
112
-
113
- def test_disengage_on_gas_interceptor (self ):
114
- for g in range (0 , 0x1000 ):
115
- self ._rx (honda_interceptor_msg (0 , 0x201 ))
116
- self .safety .set_controls_allowed (True )
117
- self ._rx (honda_interceptor_msg (g , 0x201 ))
118
- remain_enabled = g <= INTERCEPTOR_THRESHOLD
119
- self .assertEqual (remain_enabled , self .safety .get_controls_allowed ())
120
- self ._rx (honda_interceptor_msg (0 , 0x201 ))
121
- self .safety .set_gas_interceptor_detected (False )
122
-
123
- def test_unsafe_mode_no_disengage_on_gas_interceptor (self ):
124
- self .safety .set_controls_allowed (True )
125
- self .safety .set_unsafe_mode (UNSAFE_MODE .DISABLE_DISENGAGE_ON_GAS )
126
- for g in range (0 , 0x1000 ):
127
- self ._rx (honda_interceptor_msg (g , 0x201 ))
128
- self .assertTrue (self .safety .get_controls_allowed ())
129
- self ._rx (honda_interceptor_msg (0 , 0x201 ))
130
- self .safety .set_gas_interceptor_detected (False )
131
- self .safety .set_unsafe_mode (UNSAFE_MODE .DEFAULT )
132
- self .safety .set_controls_allowed (False )
133
-
134
- def test_allow_engage_with_gas_interceptor_pressed (self ):
135
- self ._rx (honda_interceptor_msg (0x1000 , 0x201 ))
136
- self .safety .set_controls_allowed (1 )
137
- self ._rx (honda_interceptor_msg (0x1000 , 0x201 ))
138
- self .assertTrue (self .safety .get_controls_allowed ())
139
- self ._rx (honda_interceptor_msg (0 , 0x201 ))
140
- self .safety .set_gas_interceptor_detected (False )
141
-
142
95
def test_steer_safety_check (self ):
143
96
self .safety .set_controls_allowed (0 )
144
97
self .assertTrue (self ._tx (self ._send_steer_msg (0x0000 )))
@@ -223,7 +176,7 @@ def test_tx_hook_on_pedal_pressed(self):
223
176
self ._rx (self ._gas_msg (0 ))
224
177
225
178
226
- class TestHondaNidecSafety (TestHondaSafety ):
179
+ class TestHondaNidecSafety (TestHondaSafety , common . InterceptorSafetyTest ):
227
180
228
181
TX_MSGS = [[0xE4 , 0 ], [0x194 , 0 ], [0x1FA , 0 ], [0x200 , 0 ], [0x30C , 0 ], [0x33D , 0 ]]
229
182
STANDSTILL_THRESHOLD = 0
@@ -232,12 +185,22 @@ class TestHondaNidecSafety(TestHondaSafety):
232
185
FWD_BLACKLISTED_ADDRS = {2 : [0xE4 , 0x194 , 0x33D , 0x30C ]}
233
186
FWD_BUS_LOOKUP = {0 : 2 , 2 : 0 }
234
187
188
+ INTERCEPTOR_THRESHOLD = 344
189
+
235
190
def setUp (self ):
236
191
self .packer = CANPackerPanda ("honda_civic_touring_2016_can_generated" )
237
192
self .safety = libpandasafety_py .libpandasafety
238
193
self .safety .set_safety_hooks (Panda .SAFETY_HONDA_NIDEC , 0 )
239
194
self .safety .init_tests_honda ()
240
195
196
+ # Honda gas gains are the different
197
+ def _interceptor_msg (self , gas , addr ):
198
+ to_send = make_msg (0 , addr , 6 )
199
+ gas2 = gas * 2
200
+ to_send [0 ].RDLR = ((gas & 0xff ) << 8 ) | ((gas & 0xff00 ) >> 8 ) | \
201
+ ((gas2 & 0xff ) << 24 ) | ((gas2 & 0xff00 ) << 8 )
202
+ return to_send
203
+
241
204
def test_fwd_hook (self ):
242
205
# normal operation, not forwarding AEB
243
206
self .FWD_BLACKLISTED_ADDRS [2 ].append (0x1FA )
@@ -265,36 +228,26 @@ def test_brake_safety_check(self):
265
228
self .assertEqual (send , self ._tx (self ._send_brake_msg (brake )))
266
229
self .safety .set_honda_fwd_brake (False )
267
230
268
- def test_gas_interceptor_safety_check (self ):
269
- for gas in np .arange (0 , 4000 , 100 ):
270
- for controls_allowed in [True , False ]:
271
- self .safety .set_controls_allowed (controls_allowed )
272
- if controls_allowed :
273
- send = True
274
- else :
275
- send = gas == 0
276
- self .assertEqual (send , self ._tx (honda_interceptor_msg (gas , 0x200 )))
277
-
278
231
def test_tx_hook_on_interceptor_pressed (self ):
279
232
for mode in [UNSAFE_MODE .DEFAULT , UNSAFE_MODE .DISABLE_DISENGAGE_ON_GAS ]:
280
233
self .safety .set_unsafe_mode (mode )
281
234
# gas_interceptor_prev > INTERCEPTOR_THRESHOLD
282
- self ._rx (honda_interceptor_msg ( INTERCEPTOR_THRESHOLD + 1 , 0x201 ))
283
- self ._rx (honda_interceptor_msg ( INTERCEPTOR_THRESHOLD + 1 , 0x201 ))
235
+ self ._rx (self . _interceptor_msg ( self . INTERCEPTOR_THRESHOLD + 1 , 0x201 ))
236
+ self ._rx (self . _interceptor_msg ( self . INTERCEPTOR_THRESHOLD + 1 , 0x201 ))
284
237
allow_ctrl = mode == UNSAFE_MODE .DISABLE_DISENGAGE_ON_GAS
285
238
286
239
self .safety .set_controls_allowed (1 )
287
240
self .safety .set_honda_fwd_brake (False )
288
241
self .assertEqual (allow_ctrl , self ._tx (self ._send_brake_msg (MAX_BRAKE )))
289
- self .assertEqual (allow_ctrl , self ._tx (honda_interceptor_msg ( INTERCEPTOR_THRESHOLD , 0x200 )))
242
+ self .assertEqual (allow_ctrl , self ._tx (self . _interceptor_msg ( self . INTERCEPTOR_THRESHOLD , 0x200 )))
290
243
self .assertEqual (allow_ctrl , self ._tx (self ._send_steer_msg (0x1000 )))
291
244
292
245
# reset status
293
246
self .safety .set_controls_allowed (0 )
294
247
self .safety .set_unsafe_mode (UNSAFE_MODE .DEFAULT )
295
248
self ._tx (self ._send_brake_msg (0 ))
296
249
self ._tx (self ._send_steer_msg (0 ))
297
- self ._tx (honda_interceptor_msg (0 , 0x200 ))
250
+ self ._tx (self . _interceptor_msg (0 , 0x200 ))
298
251
self .safety .set_gas_interceptor_detected (False )
299
252
300
253
0 commit comments