From 8c3bb0151e8907ade344ccb293d58cd543e28baa Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 30 Jul 2024 21:20:48 -0700 Subject: [PATCH] deprecate busTime (#1989) * deprecate busTime * fix test_comms.py * update opendbc * way more than i thought * and here * oops --- Dockerfile | 2 +- board/jungle/scripts/can_printer.py | 2 +- board/jungle/scripts/echo_loopback_test.py | 2 +- board/jungle/scripts/loopback_test.py | 4 ++-- examples/can_logger.py | 2 +- examples/tesla_tester.py | 2 +- python/__init__.py | 6 +++--- python/ccp.py | 2 +- python/isotp.py | 6 +++--- python/xcp.py | 2 +- tests/black_white_loopback_test.py | 6 +++--- tests/black_white_relay_endurance.py | 6 +++--- tests/black_white_relay_test.py | 4 ++-- tests/bulk_write_test.py | 2 +- tests/can_printer.py | 2 +- tests/canfd/test_canfd.py | 4 ++-- tests/echo.py | 2 +- tests/elm_car_simulator.py | 6 +++--- tests/hitl/3_usb_to_can.py | 12 ++++++------ tests/hitl/4_can_loopback.py | 18 +++++++++--------- tests/hitl/6_safety.py | 4 ++-- tests/hitl/9_harness.py | 2 +- tests/hitl/helpers.py | 12 ++++++------ tests/loopback_test.py | 12 ++++++------ tests/message_drop_test.py | 4 ++-- tests/safety/common.py | 2 +- tests/safety/test_ford.py | 4 ++-- tests/safety/test_hyundai.py | 4 ++-- tests/usbprotocol/test_comms.py | 16 ++++++++-------- tests/usbprotocol/test_pandalib.py | 2 +- 30 files changed, 77 insertions(+), 77 deletions(-) diff --git a/Dockerfile b/Dockerfile index 74afcb6b5..1a6122ee0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,7 +48,7 @@ RUN /tmp/install.sh && rm -rf $CPPCHECK_DIR/.git/ ENV SKIP_CPPCHECK_INSTALL=1 ENV CEREAL_REF="861144c136c91f70dcbc652c2ffe99f57440ad47" -ENV OPENDBC_REF="e0d4be4a6215d44809718dc84efe1b9f0299ad63" +ENV OPENDBC_REF="8e9d3688412405154a8189c421cfdc9d5feea715" RUN git config --global --add safe.directory /tmp/openpilot/panda RUN mkdir -p /tmp/openpilot/ && \ diff --git a/board/jungle/scripts/can_printer.py b/board/jungle/scripts/can_printer.py index 675fc508a..f620d6f12 100755 --- a/board/jungle/scripts/can_printer.py +++ b/board/jungle/scripts/can_printer.py @@ -19,7 +19,7 @@ def can_printer(): canbus = int(os.getenv("CAN", "0")) while True: can_recv = p.can_recv() - for address, _, dat, src in can_recv: + for address, dat, src in can_recv: if src == canbus: msgs[address].append(dat) diff --git a/board/jungle/scripts/echo_loopback_test.py b/board/jungle/scripts/echo_loopback_test.py index 78b65b534..2cc523c8f 100755 --- a/board/jungle/scripts/echo_loopback_test.py +++ b/board/jungle/scripts/echo_loopback_test.py @@ -37,7 +37,7 @@ def test_loopback(): incoming = jungle.can_recv() found = False for message in incoming: - incomingAddress, _, incomingData, incomingBus = message + incomingAddress, incomingData, incomingBus = message if incomingAddress == address and incomingData == data[::-1] and incomingBus == bus: found = True break diff --git a/board/jungle/scripts/loopback_test.py b/board/jungle/scripts/loopback_test.py index 10caf42cc..b7be5586b 100755 --- a/board/jungle/scripts/loopback_test.py +++ b/board/jungle/scripts/loopback_test.py @@ -74,11 +74,11 @@ def can_loopback(sender): raise Exception("Amount of received CAN messages (" + str(len(content)) + ") does not equal 1. Bus: " + str(bus) +" OBD: " + str(obd)) # Check content - if content[0][0] != addr or content[0][2] != string: + if content[0][0] != addr or content[0][1] != string: raise Exception("Received CAN message content or address does not match") # Check bus - if content[0][3] != bus: + if content[0][2] != bus: raise Exception("Received CAN message bus does not match") ################################################################# diff --git a/examples/can_logger.py b/examples/can_logger.py index aed3ac9d6..2bf4359ca 100755 --- a/examples/can_logger.py +++ b/examples/can_logger.py @@ -22,7 +22,7 @@ def can_logger(): while True: can_recv = p.can_recv() - for address, _, dat, src in can_recv: + for address, dat, src in can_recv: csvwriter.writerow( [str(src), str(hex(address)), f"0x{dat.hex()}", len(dat), str(time.time() - start_time)]) diff --git a/examples/tesla_tester.py b/examples/tesla_tester.py index 966e39d10..48a6b7de6 100755 --- a/examples/tesla_tester.py +++ b/examples/tesla_tester.py @@ -34,7 +34,7 @@ def tesla_tester(): while True: #Read the VIN can_recv = p.can_recv() - for address, _, dat, src in can_recv: + for address, dat, src in can_recv: if src == body_bus_num: if address == 1384: # 0x568 is VIN vin_index = int(binascii.hexlify(dat)[:2]) # first byte is the index, 00, 01, 02 diff --git a/python/__init__.py b/python/__init__.py index a18fdc5f9..32a6308dd 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -37,7 +37,7 @@ def calculate_checksum(data): def pack_can_buffer(arr): snds = [b''] - for address, _, dat, bus in arr: + for address, dat, bus in arr: assert len(dat) in LEN_TO_DLC #logging.debug(" W 0x%x: 0x%s", address, dat.hex()) @@ -85,7 +85,7 @@ def unpack_can_buffer(dat): data = dat[CANPACKET_HEAD_SIZE:(CANPACKET_HEAD_SIZE+data_len)] dat = dat[(CANPACKET_HEAD_SIZE+data_len):] - ret.append((address, 0, data, bus)) + ret.append((address, data, bus)) return (ret, dat) @@ -812,7 +812,7 @@ class Panda: logging.error("CAN: BAD SEND MANY, RETRYING") def can_send(self, addr, dat, bus, timeout=CAN_SEND_TIMEOUT_MS): - self.can_send_many([[addr, None, dat, bus]], timeout=timeout) + self.can_send_many([[addr, dat, bus]], timeout=timeout) @ensure_can_packet_version def can_recv(self): diff --git a/python/ccp.py b/python/ccp.py index 50a5f87a3..3ba1ef358 100644 --- a/python/ccp.py +++ b/python/ccp.py @@ -99,7 +99,7 @@ class CcpClient(): msgs = self._panda.can_recv() or [] if len(msgs) >= 256: print("CAN RX buffer overflow!!!", file=sys.stderr) - for rx_addr, _, rx_data_bytearray, rx_bus in msgs: + for rx_addr, rx_data_bytearray, rx_bus in msgs: if rx_bus == self.can_bus and rx_addr == self.rx_addr: rx_data = bytes(rx_data_bytearray) if self.debug: diff --git a/python/isotp.py b/python/isotp.py index d0bef7d94..ac64c413b 100644 --- a/python/isotp.py +++ b/python/isotp.py @@ -18,12 +18,12 @@ def recv(panda, cnt, addr, nbus): while len(ret) < cnt: kmsgs += panda.can_recv() nmsgs = [] - for ids, ts, dat, bus in kmsgs: + for ids, dat, bus in kmsgs: if ids == addr and bus == nbus and len(ret) < cnt: ret.append(dat) else: # leave around - nmsgs.append((ids, ts, dat, bus)) + nmsgs.append((ids, dat, bus)) kmsgs = nmsgs[-256:] return ret @@ -96,7 +96,7 @@ def isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None, rate=None): panda.can_send(addr, sends[-1], 0) else: if rate is None: - panda.can_send_many([(addr, None, s, bus) for s in sends]) + panda.can_send_many([(addr, s, bus) for s in sends]) else: for dat in sends: panda.can_send(addr, dat, bus) diff --git a/python/xcp.py b/python/xcp.py index bb294046e..066ed9885 100644 --- a/python/xcp.py +++ b/python/xcp.py @@ -145,7 +145,7 @@ class XcpClient(): msgs = self._panda.can_recv() or [] if len(msgs) >= 256: print("CAN RX buffer overflow!!!", file=sys.stderr) - for rx_addr, _, rx_data, rx_bus in msgs: + for rx_addr, rx_data, rx_bus in msgs: if rx_bus == self.can_bus and rx_addr == self.rx_addr: rx_data = bytes(rx_data) # convert bytearray to bytes if self.debug: diff --git a/tests/black_white_loopback_test.py b/tests/black_white_loopback_test.py index 8198a30d5..69b0cfbd1 100755 --- a/tests/black_white_loopback_test.py +++ b/tests/black_white_loopback_test.py @@ -118,11 +118,11 @@ def test_buses(black_panda, other_panda, direction, test_array, sleep_duration): loop_buses = [] for loop in cans_loop: - if (loop[0] != at) or (loop[2] != st): + if (loop[0] != at) or (loop[1] != st): content_errors += 1 - print(" Loop on bus", str(loop[3])) - loop_buses.append(loop[3]) + print(" Loop on bus", str(loop[2])) + loop_buses.append(loop[2]) if len(cans_loop) == 0: print(" No loop") assert not os.getenv("NOASSERT") diff --git a/tests/black_white_relay_endurance.py b/tests/black_white_relay_endurance.py index 005277c15..433f12343 100755 --- a/tests/black_white_relay_endurance.py +++ b/tests/black_white_relay_endurance.py @@ -126,11 +126,11 @@ def test_buses(black_panda, other_panda, direction, test_array, sleep_duration): loop_buses = [] for loop in cans_loop: - if (loop[0] != at) or (loop[2] != st): + if (loop[0] != at) or (loop[1] != st): content_errors += 1 - print(" Loop on bus", str(loop[3])) - loop_buses.append(loop[3]) + print(" Loop on bus", str(loop[2])) + loop_buses.append(loop[2]) if len(cans_loop) == 0: print(" No loop") assert os.getenv("NOASSERT") diff --git a/tests/black_white_relay_test.py b/tests/black_white_relay_test.py index 38db06a1a..dce44f567 100755 --- a/tests/black_white_relay_test.py +++ b/tests/black_white_relay_test.py @@ -109,9 +109,9 @@ def test_buses(black_panda, other_panda, test_obj): loop_buses = [] for loop in cans_loop: - if (loop[0] != at) or (loop[2] != st): + if (loop[0] != at) or (loop[1] != st): content_errors += 1 - loop_buses.append(loop[3]) + loop_buses.append(loop[2]) # test loop buses recv_buses.sort() diff --git a/tests/bulk_write_test.py b/tests/bulk_write_test.py index 278766a19..e886efb06 100755 --- a/tests/bulk_write_test.py +++ b/tests/bulk_write_test.py @@ -16,7 +16,7 @@ NUM_MESSAGES_PER_BUS = 10000 def flood_tx(panda): print('Sending!') msg = b"\xaa" * 4 - packet = [[0xaa, None, msg, 0], [0xaa, None, msg, 1], [0xaa, None, msg, 2]] * NUM_MESSAGES_PER_BUS + packet = [[0xaa, msg, 0], [0xaa, msg, 1], [0xaa, msg, 2]] * NUM_MESSAGES_PER_BUS panda.can_send_many(packet, timeout=10000) print(f"Done sending {3*NUM_MESSAGES_PER_BUS} messages!") diff --git a/tests/can_printer.py b/tests/can_printer.py index 15ce89f68..08315560e 100755 --- a/tests/can_printer.py +++ b/tests/can_printer.py @@ -20,7 +20,7 @@ def can_printer(): canbus = int(os.getenv("CAN", "0")) while True: can_recv = p.can_recv() - for address, _, dat, src in can_recv: + for address, dat, src in can_recv: if src == canbus: msgs[address].append(dat) diff --git a/tests/canfd/test_canfd.py b/tests/canfd/test_canfd.py index 873bc796b..500a69aa0 100755 --- a/tests/canfd/test_canfd.py +++ b/tests/canfd/test_canfd.py @@ -86,7 +86,7 @@ def canfd_test(p_send, p_recv): data = bytearray(random.getrandbits(8) for _ in range(DLC_TO_LEN[dlc])) if len(data) >= 2: data[0] = calculate_checksum(data[1:] + bytes(str(address), encoding="utf-8")) - to_send.append([address, 0, data, bus]) + to_send.append([address, data, bus]) sent_msgs[bus].add((address, bytes(data))) p_send.can_send_many(to_send, timeout=0) @@ -95,7 +95,7 @@ def canfd_test(p_send, p_recv): while (time.monotonic() - start_time < 1) and any(len(x) > 0 for x in sent_msgs.values()): incoming = p_recv.can_recv() for msg in incoming: - address, _, data, bus = msg + address, data, bus = msg if len(data) >= 2: assert calculate_checksum(data[1:] + bytes(str(address), encoding="utf-8")) == data[0] k = (address, bytes(data)) diff --git a/tests/echo.py b/tests/echo.py index 90bf4a8c7..1c20561b1 100755 --- a/tests/echo.py +++ b/tests/echo.py @@ -11,6 +11,6 @@ if __name__ == "__main__": while True: incoming = p.can_recv() for message in incoming: - address, notused, data, bus = message + address, data, bus = message if b'test' in data: p.can_send(address, data[::-1], bus) diff --git a/tests/elm_car_simulator.py b/tests/elm_car_simulator.py index 56e825f5d..90024a254 100755 --- a/tests/elm_car_simulator.py +++ b/tests/elm_car_simulator.py @@ -77,11 +77,11 @@ class ELMCarSimulator(): self.panda.can_recv() # Toss whatever was already there while not self.__stop: - for address, ts, data, src in self.panda.can_recv(): + for address, data, src in self.panda.can_recv(): if self.__on and src == 0 and len(data) == 8 and data[0] >= 2: if not self.__silent: print("Processing CAN message", src, hex(address), binascii.hexlify(data)) - self.__can_process_msg(data[1], data[2], address, ts, data, src) + self.__can_process_msg(data[1], data[2], address, data, src) elif not self.__silent: print("Rejecting CAN message", src, hex(address), binascii.hexlify(data)) @@ -120,7 +120,7 @@ class ELMCarSimulator(): return True return False - def __can_process_msg(self, mode, pid, address, ts, data, src): + def __can_process_msg(self, mode, pid, address, data, src): if not self.__silent: print("CAN MSG", binascii.hexlify(data[1:1 + data[0]]), "Addr:", hex(address), "Mode:", hex(mode)[2:].zfill(2), diff --git a/tests/hitl/3_usb_to_can.py b/tests/hitl/3_usb_to_can.py index c0a9035fe..9920f44a8 100644 --- a/tests/hitl/3_usb_to_can.py +++ b/tests/hitl/3_usb_to_can.py @@ -18,14 +18,14 @@ def test_can_loopback(p): # confirm receive both on loopback and send receipt time.sleep(0.05) r = p.can_recv() - sr = [x for x in r if x[3] == 0x80 | bus] - lb = [x for x in r if x[3] == bus] + sr = [x for x in r if x[2] == 0x80 | bus] + lb = [x for x in r if x[2] == bus] assert len(sr) == 1 assert len(lb) == 1 # confirm data is correct assert 0x1aa == sr[0][0] == lb[0][0] - assert b"message" == sr[0][2] == lb[0][2] + assert b"message" == sr[0][1] == lb[0][1] def test_reliability(p): MSG_COUNT = 100 @@ -35,7 +35,7 @@ def test_reliability(p): p.set_can_speed_kbps(0, 1000) addrs = list(range(100, 100 + MSG_COUNT)) - ts = [(j, 0, b"\xaa" * 8, 0) for j in addrs] + ts = [(j, b"\xaa" * 8, 0) for j in addrs] for _ in range(100): st = time.monotonic() @@ -46,8 +46,8 @@ def test_reliability(p): while len(r) < 200 and (time.monotonic() - st) < 0.5: r.extend(p.can_recv()) - sent_echo = [x for x in r if x[3] == 0x80] - loopback_resp = [x for x in r if x[3] == 0] + sent_echo = [x for x in r if x[2] == 0x80] + loopback_resp = [x for x in r if x[2] == 0] assert sorted([x[0] for x in loopback_resp]) == addrs assert sorted([x[0] for x in sent_echo]) == addrs diff --git a/tests/hitl/4_can_loopback.py b/tests/hitl/4_can_loopback.py index a7e1aea1e..c482ba822 100644 --- a/tests/hitl/4_can_loopback.py +++ b/tests/hitl/4_can_loopback.py @@ -118,10 +118,10 @@ def test_gen2_loopback(p, panda_jungle): assert len(content) == 1 # Check content - assert content[0][0] == addr and content[0][2] == string + assert content[0][0] == addr and content[0][1] == string # Check bus - assert content[0][3] == bus + assert content[0][2] == bus print("Bus:", bus, "address:", addr, "OBD:", obd, "OK") @@ -148,9 +148,9 @@ def test_bulk_write(p, panda_jungle): msg = b"\xaa" * 8 packet = [] # start with many messages on a single bus (higher contention for single TX ring buffer) - packet += [[0xaa, None, msg, 0]] * NUM_MESSAGES_PER_BUS + packet += [[0xaa, msg, 0]] * NUM_MESSAGES_PER_BUS # end with many messages on multiple buses - packet += [[0xaa, None, msg, 0], [0xaa, None, msg, 1], [0xaa, None, msg, 2]] * NUM_MESSAGES_PER_BUS + packet += [[0xaa, msg, 0], [0xaa, msg, 1], [0xaa, msg, 2]] * NUM_MESSAGES_PER_BUS # Disable timeout panda.set_safety_mode(Panda.SAFETY_ALLOUTPUT) @@ -182,18 +182,18 @@ def test_message_integrity(p): for _ in range(random.randrange(10)): to_send = get_random_can_messages(random.randrange(100)) for m in to_send: - sent_msgs[m[3]].add((m[0], m[2])) + sent_msgs[m[2]].add((m[0], m[1])) p.can_send_many(to_send, timeout=0) start_time = time.monotonic() while time.monotonic() - start_time < 2 and any(len(sent_msgs[bus]) for bus in range(3)): recvd = p.can_recv() for msg in recvd: - if msg[3] >= 128: - k = (msg[0], bytes(msg[2])) - bus = msg[3]-128 + if msg[2] >= 128: + k = (msg[0], bytes(msg[1])) + bus = msg[2]-128 assert k in sent_msgs[bus], f"message {k} was never sent on bus {bus}" - sent_msgs[msg[3]-128].discard(k) + sent_msgs[msg[2]-128].discard(k) # if a set isn't empty, messages got dropped for bus in range(3): diff --git a/tests/hitl/6_safety.py b/tests/hitl/6_safety.py index 2237f5303..67c646166 100644 --- a/tests/hitl/6_safety.py +++ b/tests/hitl/6_safety.py @@ -14,8 +14,8 @@ def test_safety_nooutput(p): time.sleep(0.05) r = p.can_recv() # bus 192 is messages blocked by TX safety hook on bus 0 - assert len([x for x in r if x[3] != 192]) == 0 - assert len([x for x in r if x[3] == 192]) == 1 + assert len([x for x in r if x[2] != 192]) == 0 + assert len([x for x in r if x[2] == 192]) == 1 def test_canfd_safety_modes(p): diff --git a/tests/hitl/9_harness.py b/tests/hitl/9_harness.py index 5689892b8..b3544899b 100644 --- a/tests/hitl/9_harness.py +++ b/tests/hitl/9_harness.py @@ -51,7 +51,7 @@ def test_harness_status(p, panda_jungle): time.sleep(0.5) msgs = p.can_recv() - buses = {int(dat): bus for _, _, dat, bus in msgs if bus <= 3} + buses = {int(dat): bus for _, dat, bus in msgs if bus <= 3} print(msgs) # jungle doesn't actually switch buses when switching orientation diff --git a/tests/hitl/helpers.py b/tests/hitl/helpers.py index 4eee43731..d46567130 100644 --- a/tests/hitl/helpers.py +++ b/tests/hitl/helpers.py @@ -8,7 +8,7 @@ def get_random_can_messages(n): bus = random.randrange(3) addr = random.randrange(1 << 29) dat = bytes([random.getrandbits(8) for _ in range(random.randrange(1, 9))]) - m.append([addr, None, dat, bus]) + m.append([addr, dat, bus]) return m @@ -19,7 +19,7 @@ def time_many_sends(p, bus, p_recv=None, msg_count=100, two_pandas=False, msg_le raise ValueError("Cannot have two pandas that are the same panda") msg_id = random.randint(0x100, 0x200) - to_send = [(msg_id, 0, b"\xaa" * msg_len, bus)] * msg_count + to_send = [(msg_id, b"\xaa" * msg_len, bus)] * msg_count start_time = time.monotonic() p.can_send_many(to_send) @@ -35,11 +35,11 @@ def time_many_sends(p, bus, p_recv=None, msg_count=100, two_pandas=False, msg_le while len(r_echo) < r_echo_len_exected and (time.monotonic() - start_time) < 10: r_echo.extend(p.can_recv()) - sent_echo = [x for x in r if x[3] == 0x80 | bus and x[0] == msg_id] - sent_echo.extend([x for x in r_echo if x[3] == 0x80 | bus and x[0] == msg_id]) - resp = [x for x in r if x[3] == bus and x[0] == msg_id] + sent_echo = [x for x in r if x[2] == 0x80 | bus and x[0] == msg_id] + sent_echo.extend([x for x in r_echo if x[2] == 0x80 | bus and x[0] == msg_id]) + resp = [x for x in r if x[2] == bus and x[0] == msg_id] - leftovers = [x for x in r if (x[3] != 0x80 | bus and x[3] != bus) or x[0] != msg_id] + leftovers = [x for x in r if (x[2] != 0x80 | bus and x[2] != bus) or x[0] != msg_id] assert len(leftovers) == 0 assert len(resp) == msg_count diff --git a/tests/loopback_test.py b/tests/loopback_test.py index a95c2ea22..2b6eb5308 100755 --- a/tests/loopback_test.py +++ b/tests/loopback_test.py @@ -69,13 +69,13 @@ def run_test_w_pandas(pandas, sleep_duration): assert cans_echo[0][0] == at assert cans_loop[0][0] == at - assert cans_echo[0][2] == st - assert cans_loop[0][2] == st + assert cans_echo[0][1] == st + assert cans_loop[0][1] == st - assert cans_echo[0][3] == 0x80 | bus - if cans_loop[0][3] != bus: - print("EXPECTED %d GOT %d" % (bus, cans_loop[0][3])) - assert cans_loop[0][3] == bus + assert cans_echo[0][2] == 0x80 | bus + if cans_loop[0][2] != bus: + print("EXPECTED %d GOT %d" % (bus, cans_loop[0][2])) + assert cans_loop[0][2] == bus print("CAN pass", bus, ho) time.sleep(sleep_duration) diff --git a/tests/message_drop_test.py b/tests/message_drop_test.py index bf485e454..a131a9c91 100755 --- a/tests/message_drop_test.py +++ b/tests/message_drop_test.py @@ -16,7 +16,7 @@ if JUNGLE: # Generate unique messages NUM_MESSAGES_PER_BUS = 10000 messages = [bytes(struct.pack("Q", i)) for i in range(NUM_MESSAGES_PER_BUS)] -tx_messages = list(itertools.chain.from_iterable([[0xaa, None, msg, 0], [0xaa, None, msg, 1], [0xaa, None, msg, 2]] for msg in messages)) +tx_messages = list(itertools.chain.from_iterable([[0xaa, msg, 0], [0xaa, msg, 1], [0xaa, msg, 2]] for msg in messages)) def flood_tx(panda): print('Sending!') @@ -65,6 +65,6 @@ if __name__ == "__main__": # Check if we received everything for bus in range(3): - received_msgs = {bytes(m[2]) for m in filter(lambda m, b=bus: m[3] == b, rx)} # type: ignore + received_msgs = {bytes(m[1]) for m in filter(lambda m, b=bus: m[2] == b, rx)} # type: ignore dropped_msgs = set(messages).difference(received_msgs) print(f"Bus {bus} dropped msgs: {len(list(dropped_msgs))} / {len(messages)}") diff --git a/tests/safety/common.py b/tests/safety/common.py index e111ff7ef..884f21a36 100644 --- a/tests/safety/common.py +++ b/tests/safety/common.py @@ -30,7 +30,7 @@ class CANPackerPanda(CANPacker): msg = self.make_can_msg(name_or_addr, bus, values) if fix_checksum is not None: msg = fix_checksum(msg) - addr, _, dat, bus = msg + addr, dat, bus = msg return libpanda_py.make_CANPacket(addr, bus, dat) diff --git a/tests/safety/test_ford.py b/tests/safety/test_ford.py index 1be3a273c..710462ae9 100755 --- a/tests/safety/test_ford.py +++ b/tests/safety/test_ford.py @@ -24,7 +24,7 @@ MSG_IPMA_Data = 0x3D8 # TX by OP, IPMA and LKAS user interface def checksum(msg): - addr, t, dat, bus = msg + addr, dat, bus = msg ret = bytearray(dat) if addr == MSG_Yaw_Data_FD1: @@ -50,7 +50,7 @@ def checksum(msg): chksum = 0xff - (chksum & 0xff) ret[1] = chksum - return addr, t, ret, bus + return addr, ret, bus class Buttons: diff --git a/tests/safety/test_hyundai.py b/tests/safety/test_hyundai.py index fbe7d1032..1bff99fa7 100755 --- a/tests/safety/test_hyundai.py +++ b/tests/safety/test_hyundai.py @@ -11,7 +11,7 @@ from panda.tests.safety.hyundai_common import HyundaiButtonBase, HyundaiLongitud # 4 bit checkusm used in some hyundai messages # lives outside the can packer because we never send this msg def checksum(msg): - addr, t, dat, bus = msg + addr, dat, bus = msg chksum = 0 if addr == 0x386: @@ -40,7 +40,7 @@ def checksum(msg): ret = bytearray(dat) ret[6 if addr == 0x394 else 7] |= chksum << (4 if addr == 0x421 else 0) - return addr, t, ret, bus + return addr, ret, bus class TestHyundaiSafety(HyundaiButtonBase, common.PandaCarSafetyTest, common.DriverTorqueSteeringSafetyTest, common.SteerRequestCutSafetyTest): diff --git a/tests/usbprotocol/test_comms.py b/tests/usbprotocol/test_comms.py index 8efefef7c..e649bdaea 100755 --- a/tests/usbprotocol/test_comms.py +++ b/tests/usbprotocol/test_comms.py @@ -14,7 +14,7 @@ TX_QUEUES = (lpp.tx1_q, lpp.tx2_q, lpp.tx3_q) def unpackage_can_msg(pkt): dat_len = DLC_TO_LEN[pkt[0].data_len_code] dat = bytes(pkt[0].data[0:dat_len]) - return pkt[0].addr, 0, dat, pkt[0].bus + return pkt[0].addr, dat, pkt[0].bus def random_can_messages(n, bus=None): @@ -24,7 +24,7 @@ def random_can_messages(n, bus=None): bus = random.randint(0, 3) address = random.randint(1, (1 << 29) - 1) data = bytes([random.getrandbits(8) for _ in range(DLC_TO_LEN[random.randrange(0, len(DLC_TO_LEN))])]) - msgs.append((address, 0, data, bus)) + msgs.append((address, data, bus)) return msgs @@ -34,9 +34,9 @@ class TestPandaComms(unittest.TestCase): def test_tx_queues(self): for bus in range(len(TX_QUEUES)): - message = (0x100, 0, b"test", bus) + message = (0x100, b"test", bus) - can_pkt_tx = libpanda_py.make_CANPacket(message[0], message[3], message[2]) + can_pkt_tx = libpanda_py.make_CANPacket(message[0], message[2], message[1]) can_pkt_rx = libpanda_py.ffi.new('CANPacket_t *') assert lpp.can_push(TX_QUEUES[bus], can_pkt_tx), "CAN push failed" @@ -46,9 +46,9 @@ class TestPandaComms(unittest.TestCase): def test_comms_reset_rx(self): # store some test messages in the queue - test_msg = (0x100, 0, b"test", 0) + test_msg = (0x100, b"test", 0) for _ in range(100): - can_pkt_tx = libpanda_py.make_CANPacket(test_msg[0], test_msg[3], test_msg[2]) + can_pkt_tx = libpanda_py.make_CANPacket(test_msg[0], test_msg[2], test_msg[1]) lpp.can_push(lpp.rx_q, can_pkt_tx) # read a small chunk such that we have some overflow @@ -76,7 +76,7 @@ class TestPandaComms(unittest.TestCase): def test_comms_reset_tx(self): # store some test messages in the queue - test_msg = (0x100, 0, b"test", 0) + test_msg = (0x100, b"test", 0) packed = pack_can_buffer([test_msg for _ in range(100)]) # write a small chunk such that we have some overflow @@ -126,7 +126,7 @@ class TestPandaComms(unittest.TestCase): def test_can_receive_usb(self): msgs = random_can_messages(50000) - packets = [libpanda_py.make_CANPacket(m[0], m[3], m[2]) for m in msgs] + packets = [libpanda_py.make_CANPacket(m[0], m[2], m[1]) for m in msgs] rx_msgs = [] overflow_buf = b"" diff --git a/tests/usbprotocol/test_pandalib.py b/tests/usbprotocol/test_pandalib.py index c03f246f3..ef725948c 100755 --- a/tests/usbprotocol/test_pandalib.py +++ b/tests/usbprotocol/test_pandalib.py @@ -12,7 +12,7 @@ class PandaTestPackUnpack(unittest.TestCase): for _ in range(10000): address = random.randint(1, (1 << 29) - 1) data = bytes([random.getrandbits(8) for _ in range(DLC_TO_LEN[random.randrange(0, len(DLC_TO_LEN))])]) - to_pack.append((address, 0, data, 0)) + to_pack.append((address, data, 0)) packed = pack_can_buffer(to_pack) unpacked = []