dragonpilot beta3

date: 2024-08-20T11:22:58
commit: dc76c1d6216e3766209a450c29dc9dafb696ef19
This commit is contained in:
dragonpilot
2024-08-20 11:22:22 +00:00
committed by Comma Device
parent 0f94adf3e2
commit c58f481a80
613 changed files with 36485 additions and 157159 deletions
+3 -3
View File
@@ -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)
@@ -813,7 +813,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):
+1 -1
View File
@@ -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:
+3 -3
View File
@@ -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)
+2 -2
View File
@@ -301,7 +301,7 @@ def get_dtc_status_names(status):
return result
class CanClient():
def __init__(self, can_send: Callable[[int, bytes, int], None], can_recv: Callable[[], list[tuple[int, int, bytes, int]]],
def __init__(self, can_send: Callable[[int, bytes, int], None], can_recv: Callable[[], list[tuple[int, bytes, int]]],
tx_addr: int, rx_addr: int, bus: int, sub_addr: int | None = None, debug: bool = False):
self.tx = can_send
self.rx = can_recv
@@ -339,7 +339,7 @@ class CanClient():
print(f"CAN-RX: drain - {len(msgs)}")
self.rx_buff.clear()
else:
for rx_addr, _, rx_data, rx_bus in msgs or []:
for rx_addr, rx_data, rx_bus in msgs or []:
if self._recv_filter(rx_bus, rx_addr) and len(rx_data) > 0:
rx_data = bytes(rx_data) # convert bytearray to bytes
+1 -1
View File
@@ -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: