Skip to content

Commit 579fff0

Browse files
authored
Safety tests: Convert message addresses from decimal to hexadecimal (#1633)
1 parent afb241a commit 579fff0

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

tests/safety/test_chrysler.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88

99
class TestChryslerSafety(common.PandaSafetyTest, common.MotorTorqueSteeringSafetyTest):
10-
TX_MSGS = [[571, 0], [658, 0], [678, 0]]
10+
TX_MSGS = [[0x23B, 0], [0x292, 0], [0x2A6, 0]]
1111
STANDSTILL_THRESHOLD = 0
1212
RELAY_MALFUNCTION_ADDR = 0x292
1313
RELAY_MALFUNCTION_BUS = 0
14-
FWD_BLACKLISTED_ADDRS = {2: [658, 678]}
14+
FWD_BLACKLISTED_ADDRS = {2: [0x292, 0x2A6]}
1515
FWD_BUS_LOOKUP = {0: 2, 2: 0}
1616

1717
MAX_RATE_UP = 3
@@ -75,9 +75,9 @@ def test_buttons(self):
7575

7676

7777
class TestChryslerRamDTSafety(TestChryslerSafety):
78-
TX_MSGS = [[177, 2], [166, 0], [250, 0]]
79-
RELAY_MALFUNCTION_ADDR = 166
80-
FWD_BLACKLISTED_ADDRS = {2: [166, 250]}
78+
TX_MSGS = [[0xB1, 2], [0xA6, 0], [0xFA, 0]]
79+
RELAY_MALFUNCTION_ADDR = 0xA6
80+
FWD_BLACKLISTED_ADDRS = {2: [0xA6, 0xFA]}
8181

8282
MAX_RATE_UP = 6
8383
MAX_RATE_DOWN = 6
@@ -98,9 +98,9 @@ def _speed_msg(self, speed):
9898
return self.packer.make_can_msg_panda("ESP_8", 0, values)
9999

100100
class TestChryslerRamHDSafety(TestChryslerSafety):
101-
TX_MSGS = [[629, 0], [630, 0], [570, 2]]
102-
RELAY_MALFUNCTION_ADDR = 630
103-
FWD_BLACKLISTED_ADDRS = {2: [629, 630]}
101+
TX_MSGS = [[0x275, 0], [0x276, 0], [0x23A, 2]]
102+
RELAY_MALFUNCTION_ADDR = 0x276
103+
FWD_BLACKLISTED_ADDRS = {2: [0x275, 0x276]}
104104

105105
MAX_TORQUE = 361
106106
MAX_RATE_UP = 14

tests/safety/test_gm.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_cancel_button(self):
7070

7171
class TestGmSafetyBase(common.PandaSafetyTest, common.DriverTorqueSteeringSafetyTest):
7272
STANDSTILL_THRESHOLD = 10 * 0.0311
73-
RELAY_MALFUNCTION_ADDR = 384
73+
RELAY_MALFUNCTION_ADDR = 0x180
7474
RELAY_MALFUNCTION_BUS = 0
7575
BUTTONS_BUS = 0 # rx or tx
7676
BRAKE_BUS = 0 # tx only
@@ -140,9 +140,9 @@ def _button_msg(self, buttons):
140140

141141

142142
class TestGmAscmSafety(GmLongitudinalBase, TestGmSafetyBase):
143-
TX_MSGS = [[384, 0], [1033, 0], [1034, 0], [715, 0], [880, 0], # pt bus
144-
[161, 1], [774, 1], [776, 1], [784, 1], # obs bus
145-
[789, 2], # ch bus
143+
TX_MSGS = [[0x180, 0], [0x409, 0], [0x40A, 0], [0x2CB, 0], [0x370, 0], # pt bus
144+
[0xA1, 1], [0x306, 1], [0x308, 1], [0x310, 1], # obs bus
145+
[0x315, 2], # ch bus
146146
[0x104c006c, 3], [0x10400060, 3]] # gmlan
147147
FWD_BLACKLISTED_ADDRS: Dict[int, List[int]] = {}
148148
FWD_BUS_LOOKUP: Dict[int, int] = {}
@@ -177,9 +177,9 @@ def _user_brake_msg(self, brake):
177177

178178

179179
class TestGmCameraSafety(TestGmCameraSafetyBase):
180-
TX_MSGS = [[384, 0], # pt bus
181-
[388, 2]] # camera bus
182-
FWD_BLACKLISTED_ADDRS = {2: [384], 0: [388]} # block LKAS message and PSCMStatus
180+
TX_MSGS = [[0x180, 0], # pt bus
181+
[0x184, 2]] # camera bus
182+
FWD_BLACKLISTED_ADDRS = {2: [0x180], 0: [0x184]} # block LKAS message and PSCMStatus
183183
BUTTONS_BUS = 2 # tx only
184184

185185
def setUp(self):
@@ -205,9 +205,9 @@ def test_buttons(self):
205205

206206

207207
class TestGmCameraLongitudinalSafety(GmLongitudinalBase, TestGmCameraSafetyBase):
208-
TX_MSGS = [[384, 0], [789, 0], [715, 0], [880, 0], # pt bus
209-
[388, 2]] # camera bus
210-
FWD_BLACKLISTED_ADDRS = {2: [384, 715, 880, 789], 0: [388]} # block LKAS, ACC messages and PSCMStatus
208+
TX_MSGS = [[0x180, 0], [0x315, 0], [0x2CB, 0], [0x370, 0], # pt bus
209+
[0x184, 2]] # camera bus
210+
FWD_BLACKLISTED_ADDRS = {2: [0x180, 0x2CB, 0x370, 0x315], 0: [0x184]} # block LKAS, ACC messages and PSCMStatus
211211
BUTTONS_BUS = 0 # rx only
212212

213213
MAX_GAS = 3400

tests/safety/test_hyundai.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def checksum(msg):
1313
addr, t, dat, bus = msg
1414

1515
chksum = 0
16-
if addr == 902:
16+
if addr == 0x386:
1717
for i, b in enumerate(dat):
1818
for j in range(8):
1919
# exclude checksum and counter bits
@@ -28,26 +28,26 @@ def checksum(msg):
2828
ret[7] |= (chksum & 0xc) << 4
2929
else:
3030
for i, b in enumerate(dat):
31-
if addr in [608, 1057] and i == 7:
32-
b &= 0x0F if addr == 1057 else 0xF0
33-
elif addr == 916 and i == 6:
31+
if addr in [0x260, 0x421] and i == 7:
32+
b &= 0x0F if addr == 0x421 else 0xF0
33+
elif addr == 0x394 and i == 6:
3434
b &= 0xF0
35-
elif addr == 916 and i == 7:
35+
elif addr == 0x394 and i == 7:
3636
continue
3737
chksum += sum(divmod(b, 16))
3838
chksum = (16 - chksum) % 16
3939
ret = bytearray(dat)
40-
ret[6 if addr == 916 else 7] |= chksum << (4 if addr == 1057 else 0)
40+
ret[6 if addr == 0x394 else 7] |= chksum << (4 if addr == 0x421 else 0)
4141

4242
return addr, t, ret, bus
4343

4444

4545
class TestHyundaiSafety(HyundaiButtonBase, common.PandaSafetyTest, common.DriverTorqueSteeringSafetyTest):
46-
TX_MSGS = [[832, 0], [1265, 0], [1157, 0]]
46+
TX_MSGS = [[0x340, 0], [0x4F1, 0], [0x485, 0]]
4747
STANDSTILL_THRESHOLD = 12 # 0.375 kph
48-
RELAY_MALFUNCTION_ADDR = 832
48+
RELAY_MALFUNCTION_ADDR = 0x340
4949
RELAY_MALFUNCTION_BUS = 0
50-
FWD_BLACKLISTED_ADDRS = {2: [832, 1157]}
50+
FWD_BLACKLISTED_ADDRS = {2: [0x340, 0x485]}
5151
FWD_BUS_LOOKUP = {0: 2, 2: 0}
5252

5353
MAX_RATE_UP = 3
@@ -168,11 +168,10 @@ def _user_gas_msg(self, gas):
168168
return self.packer.make_can_msg_panda("E_EMS11", 0, values, fix_checksum=checksum)
169169

170170
class TestHyundaiLongitudinalSafety(HyundaiLongitudinalBase, TestHyundaiSafety):
171-
TX_MSGS = [[832, 0], [1265, 0], [1157, 0], [1056, 0], [1057, 0], [1290, 0], [905, 0], [1186, 0], [909, 0], [1155, 0], [2000, 0]]
171+
TX_MSGS = [[0x340, 0], [0x4F1, 0], [0x485, 0], [0x420, 0], [0x421, 0], [0x50A, 0], [0x389, 0], [0x4A2, 0], [0x38D, 0], [0x483, 0], [0x7D0, 0]]
172172

173-
174-
DISABLED_ECU_UDS_MSG = (2000, 0)
175-
DISABLED_ECU_ACTUATION_MSG = (1057, 0)
173+
DISABLED_ECU_UDS_MSG = (0x7D0, 0)
174+
DISABLED_ECU_ACTUATION_MSG = (0x421, 0)
176175

177176
def setUp(self):
178177
self.packer = CANPackerPanda("hyundai_kia_generic")

0 commit comments

Comments
 (0)