From f4d077b832d46ac149c2b07dc37d777dc21237ea Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 7 Aug 2024 17:30:23 -0500 Subject: [PATCH] CANPacker: msg type is tuple (#1077) not mutable list --- opendbc/can/packer_pyx.pyx | 2 +- opendbc/can/tests/test_packer_parser.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/opendbc/can/packer_pyx.pyx b/opendbc/can/packer_pyx.pyx index 84a7e4544e..4e8ae7d564 100644 --- a/opendbc/can/packer_pyx.pyx +++ b/opendbc/can/packer_pyx.pyx @@ -50,4 +50,4 @@ cdef class CANPacker: pass cdef vector[uint8_t] val = self.pack(addr, values) - return [addr, (&val[0])[:val.size()], bus] + return addr, (&val[0])[:val.size()], bus diff --git a/opendbc/can/tests/test_packer_parser.py b/opendbc/can/tests/test_packer_parser.py index acb5acebe9..2abb8f0578 100644 --- a/opendbc/can/tests/test_packer_parser.py +++ b/opendbc/can/tests/test_packer_parser.py @@ -107,8 +107,9 @@ def rx_steering_msg(values, bad_checksum=False): msg = packer.make_can_msg("STEERING_CONTROL", 0, values) if bad_checksum: # add 1 to checksum - msg[1] = bytearray(msg[1]) - msg[1][4] = (msg[1][4] & 0xF0) | ((msg[1][4] & 0x0F) + 1) + dat = bytearray(msg[1]) + dat[4] = (dat[4] & 0xF0) | ((dat[4] & 0x0F) + 1) + msg = (msg[0], bytes(dat), msg[2]) parser.update_strings([0, [msg]]) @@ -350,6 +351,6 @@ def test_allow_undefined_msgs(self): # discovery tests in openpilot first packer = CANPacker("toyota_nodsu_pt_generated") - assert packer.make_can_msg("ACC_CONTROL", 0, {"UNKNOWN_SIGNAL": 0}) == [835, b'\x00\x00\x00\x00\x00\x00\x00N', 0] - assert packer.make_can_msg("UNKNOWN_MESSAGE", 0, {"UNKNOWN_SIGNAL": 0}) == [0, b'', 0] - assert packer.make_can_msg(0, 0, {"UNKNOWN_SIGNAL": 0}) == [0, b'', 0] + assert packer.make_can_msg("ACC_CONTROL", 0, {"UNKNOWN_SIGNAL": 0}) == (835, b'\x00\x00\x00\x00\x00\x00\x00N', 0) + assert packer.make_can_msg("UNKNOWN_MESSAGE", 0, {"UNKNOWN_SIGNAL": 0}) == (0, b'', 0) + assert packer.make_can_msg(0, 0, {"UNKNOWN_SIGNAL": 0}) == (0, b'', 0)