Safety tests: Convert message addresses from decimal to hexadecimal (#1633)

This commit is contained in:
Jason Wen 2023-08-31 23:13:37 -04:00 committed by GitHub
parent afb241ab1c
commit 579fff0c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 31 deletions

View File

@ -7,11 +7,11 @@ from panda.tests.safety.common import CANPackerPanda
class TestChryslerSafety(common.PandaSafetyTest, common.MotorTorqueSteeringSafetyTest):
TX_MSGS = [[571, 0], [658, 0], [678, 0]]
TX_MSGS = [[0x23B, 0], [0x292, 0], [0x2A6, 0]]
STANDSTILL_THRESHOLD = 0
RELAY_MALFUNCTION_ADDR = 0x292
RELAY_MALFUNCTION_BUS = 0
FWD_BLACKLISTED_ADDRS = {2: [658, 678]}
FWD_BLACKLISTED_ADDRS = {2: [0x292, 0x2A6]}
FWD_BUS_LOOKUP = {0: 2, 2: 0}
MAX_RATE_UP = 3
@ -75,9 +75,9 @@ class TestChryslerSafety(common.PandaSafetyTest, common.MotorTorqueSteeringSafet
class TestChryslerRamDTSafety(TestChryslerSafety):
TX_MSGS = [[177, 2], [166, 0], [250, 0]]
RELAY_MALFUNCTION_ADDR = 166
FWD_BLACKLISTED_ADDRS = {2: [166, 250]}
TX_MSGS = [[0xB1, 2], [0xA6, 0], [0xFA, 0]]
RELAY_MALFUNCTION_ADDR = 0xA6
FWD_BLACKLISTED_ADDRS = {2: [0xA6, 0xFA]}
MAX_RATE_UP = 6
MAX_RATE_DOWN = 6
@ -98,9 +98,9 @@ class TestChryslerRamDTSafety(TestChryslerSafety):
return self.packer.make_can_msg_panda("ESP_8", 0, values)
class TestChryslerRamHDSafety(TestChryslerSafety):
TX_MSGS = [[629, 0], [630, 0], [570, 2]]
RELAY_MALFUNCTION_ADDR = 630
FWD_BLACKLISTED_ADDRS = {2: [629, 630]}
TX_MSGS = [[0x275, 0], [0x276, 0], [0x23A, 2]]
RELAY_MALFUNCTION_ADDR = 0x276
FWD_BLACKLISTED_ADDRS = {2: [0x275, 0x276]}
MAX_TORQUE = 361
MAX_RATE_UP = 14

View File

@ -70,7 +70,7 @@ class GmLongitudinalBase(common.PandaSafetyTest, common.LongitudinalGasBrakeSafe
class TestGmSafetyBase(common.PandaSafetyTest, common.DriverTorqueSteeringSafetyTest):
STANDSTILL_THRESHOLD = 10 * 0.0311
RELAY_MALFUNCTION_ADDR = 384
RELAY_MALFUNCTION_ADDR = 0x180
RELAY_MALFUNCTION_BUS = 0
BUTTONS_BUS = 0 # rx or tx
BRAKE_BUS = 0 # tx only
@ -140,9 +140,9 @@ class TestGmSafetyBase(common.PandaSafetyTest, common.DriverTorqueSteeringSafety
class TestGmAscmSafety(GmLongitudinalBase, TestGmSafetyBase):
TX_MSGS = [[384, 0], [1033, 0], [1034, 0], [715, 0], [880, 0], # pt bus
[161, 1], [774, 1], [776, 1], [784, 1], # obs bus
[789, 2], # ch bus
TX_MSGS = [[0x180, 0], [0x409, 0], [0x40A, 0], [0x2CB, 0], [0x370, 0], # pt bus
[0xA1, 1], [0x306, 1], [0x308, 1], [0x310, 1], # obs bus
[0x315, 2], # ch bus
[0x104c006c, 3], [0x10400060, 3]] # gmlan
FWD_BLACKLISTED_ADDRS: Dict[int, List[int]] = {}
FWD_BUS_LOOKUP: Dict[int, int] = {}
@ -177,9 +177,9 @@ class TestGmCameraSafetyBase(TestGmSafetyBase):
class TestGmCameraSafety(TestGmCameraSafetyBase):
TX_MSGS = [[384, 0], # pt bus
[388, 2]] # camera bus
FWD_BLACKLISTED_ADDRS = {2: [384], 0: [388]} # block LKAS message and PSCMStatus
TX_MSGS = [[0x180, 0], # pt bus
[0x184, 2]] # camera bus
FWD_BLACKLISTED_ADDRS = {2: [0x180], 0: [0x184]} # block LKAS message and PSCMStatus
BUTTONS_BUS = 2 # tx only
def setUp(self):
@ -205,9 +205,9 @@ class TestGmCameraSafety(TestGmCameraSafetyBase):
class TestGmCameraLongitudinalSafety(GmLongitudinalBase, TestGmCameraSafetyBase):
TX_MSGS = [[384, 0], [789, 0], [715, 0], [880, 0], # pt bus
[388, 2]] # camera bus
FWD_BLACKLISTED_ADDRS = {2: [384, 715, 880, 789], 0: [388]} # block LKAS, ACC messages and PSCMStatus
TX_MSGS = [[0x180, 0], [0x315, 0], [0x2CB, 0], [0x370, 0], # pt bus
[0x184, 2]] # camera bus
FWD_BLACKLISTED_ADDRS = {2: [0x180, 0x2CB, 0x370, 0x315], 0: [0x184]} # block LKAS, ACC messages and PSCMStatus
BUTTONS_BUS = 0 # rx only
MAX_GAS = 3400

View File

@ -13,7 +13,7 @@ def checksum(msg):
addr, t, dat, bus = msg
chksum = 0
if addr == 902:
if addr == 0x386:
for i, b in enumerate(dat):
for j in range(8):
# exclude checksum and counter bits
@ -28,26 +28,26 @@ def checksum(msg):
ret[7] |= (chksum & 0xc) << 4
else:
for i, b in enumerate(dat):
if addr in [608, 1057] and i == 7:
b &= 0x0F if addr == 1057 else 0xF0
elif addr == 916 and i == 6:
if addr in [0x260, 0x421] and i == 7:
b &= 0x0F if addr == 0x421 else 0xF0
elif addr == 0x394 and i == 6:
b &= 0xF0
elif addr == 916 and i == 7:
elif addr == 0x394 and i == 7:
continue
chksum += sum(divmod(b, 16))
chksum = (16 - chksum) % 16
ret = bytearray(dat)
ret[6 if addr == 916 else 7] |= chksum << (4 if addr == 1057 else 0)
ret[6 if addr == 0x394 else 7] |= chksum << (4 if addr == 0x421 else 0)
return addr, t, ret, bus
class TestHyundaiSafety(HyundaiButtonBase, common.PandaSafetyTest, common.DriverTorqueSteeringSafetyTest):
TX_MSGS = [[832, 0], [1265, 0], [1157, 0]]
TX_MSGS = [[0x340, 0], [0x4F1, 0], [0x485, 0]]
STANDSTILL_THRESHOLD = 12 # 0.375 kph
RELAY_MALFUNCTION_ADDR = 832
RELAY_MALFUNCTION_ADDR = 0x340
RELAY_MALFUNCTION_BUS = 0
FWD_BLACKLISTED_ADDRS = {2: [832, 1157]}
FWD_BLACKLISTED_ADDRS = {2: [0x340, 0x485]}
FWD_BUS_LOOKUP = {0: 2, 2: 0}
MAX_RATE_UP = 3
@ -168,11 +168,10 @@ class TestHyundaiLegacySafetyHEV(TestHyundaiSafety):
return self.packer.make_can_msg_panda("E_EMS11", 0, values, fix_checksum=checksum)
class TestHyundaiLongitudinalSafety(HyundaiLongitudinalBase, TestHyundaiSafety):
TX_MSGS = [[832, 0], [1265, 0], [1157, 0], [1056, 0], [1057, 0], [1290, 0], [905, 0], [1186, 0], [909, 0], [1155, 0], [2000, 0]]
TX_MSGS = [[0x340, 0], [0x4F1, 0], [0x485, 0], [0x420, 0], [0x421, 0], [0x50A, 0], [0x389, 0], [0x4A2, 0], [0x38D, 0], [0x483, 0], [0x7D0, 0]]
DISABLED_ECU_UDS_MSG = (2000, 0)
DISABLED_ECU_ACTUATION_MSG = (1057, 0)
DISABLED_ECU_UDS_MSG = (0x7D0, 0)
DISABLED_ECU_ACTUATION_MSG = (0x421, 0)
def setUp(self):
self.packer = CANPackerPanda("hyundai_kia_generic")