@@ -42,15 +42,16 @@ def chrysler_checksum(msg, len_msg):
42
42
return ~ checksum & 0xFF
43
43
44
44
class TestChryslerSafety (unittest .TestCase ):
45
+ cnt_torque_meas = 0
46
+ cnt_gas = 0
47
+ cnt_cruise = 0
48
+ cnt_brake = 0
49
+
45
50
@classmethod
46
51
def setUp (cls ):
47
52
cls .safety = libpandasafety_py .libpandasafety
48
53
cls .safety .set_safety_hooks (Panda .SAFETY_CHRYSLER , 0 )
49
54
cls .safety .init_tests_chrysler ()
50
- cls .cnt_torque_meas = 0
51
- cls .cnt_gas = 0
52
- cls .cnt_cruise = 0
53
- cls .cnt_brake = 0
54
55
55
56
def _button_msg (self , buttons ):
56
57
to_send = make_msg (0 , 571 )
@@ -62,7 +63,7 @@ def _cruise_msg(self, active):
62
63
to_send [0 ].RDLR = 0x380000 if active else 0
63
64
to_send [0 ].RDHR |= (self .cnt_cruise % 16 ) << 20
64
65
to_send [0 ].RDHR |= chrysler_checksum (to_send [0 ], 8 ) << 24
65
- self .cnt_cruise += 1
66
+ self .__class__ . cnt_cruise += 1
66
67
return to_send
67
68
68
69
def _speed_msg (self , speed ):
@@ -76,15 +77,15 @@ def _gas_msg(self, gas):
76
77
to_send = make_msg (0 , 308 )
77
78
to_send [0 ].RDHR = (gas & 0x7F ) << 8
78
79
to_send [0 ].RDHR |= (self .cnt_gas % 16 ) << 20
79
- self .cnt_gas += 1
80
+ self .__class__ . cnt_gas += 1
80
81
return to_send
81
82
82
83
def _brake_msg (self , brake ):
83
84
to_send = make_msg (0 , 320 )
84
85
to_send [0 ].RDLR = 5 if brake else 0
85
86
to_send [0 ].RDHR |= (self .cnt_brake % 16 ) << 20
86
87
to_send [0 ].RDHR |= chrysler_checksum (to_send [0 ], 8 ) << 24
87
- self .cnt_brake += 1
88
+ self .__class__ . cnt_brake += 1
88
89
return to_send
89
90
90
91
def _set_prev_torque (self , t ):
@@ -97,7 +98,7 @@ def _torque_meas_msg(self, torque):
97
98
to_send [0 ].RDHR = ((torque + 1024 ) >> 8 ) + (((torque + 1024 ) & 0xff ) << 8 )
98
99
to_send [0 ].RDHR |= (self .cnt_torque_meas % 16 ) << 20
99
100
to_send [0 ].RDHR |= chrysler_checksum (to_send [0 ], 8 ) << 24
100
- self .cnt_torque_meas += 1
101
+ self .__class__ . cnt_torque_meas += 1
101
102
return to_send
102
103
103
104
def _torque_msg (self , torque ):
0 commit comments