mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 17:23:52 +08:00
TX message guaranteed delivery (#421)
* wait for tx slots before clearing nak * fix bootstub * Fixed misra * Cleanup * Added bulk write test to test USB NAK on bulk CAN messages * Added automated bulk tx test * Fixed linter * Fixed latency test influence * Added timeout to python API * Disabled can write timeout in bulk write test Co-authored-by: Robbe <robbe.derks@gmail.com>
This commit is contained in:
@@ -478,7 +478,12 @@ class Panda(object):
|
||||
|
||||
# ******************* can *******************
|
||||
|
||||
def can_send_many(self, arr):
|
||||
# The panda will NAK CAN writes when there is CAN congestion.
|
||||
# libusb will try to send it again, with a max timeout.
|
||||
# Timeout is in ms. If set to 0, the timeout is infinite.
|
||||
CAN_SEND_TIMEOUT_MS = 10
|
||||
|
||||
def can_send_many(self, arr, timeout=CAN_SEND_TIMEOUT_MS):
|
||||
snds = []
|
||||
transmit = 1
|
||||
extended = 4
|
||||
@@ -501,13 +506,13 @@ class Panda(object):
|
||||
for s in snds:
|
||||
self._handle.bulkWrite(3, s)
|
||||
else:
|
||||
self._handle.bulkWrite(3, b''.join(snds))
|
||||
self._handle.bulkWrite(3, b''.join(snds), timeout=timeout)
|
||||
break
|
||||
except (usb1.USBErrorIO, usb1.USBErrorOverflow):
|
||||
print("CAN: BAD SEND MANY, RETRYING")
|
||||
|
||||
def can_send(self, addr, dat, bus):
|
||||
self.can_send_many([[addr, None, dat, bus]])
|
||||
def can_send(self, addr, dat, bus, timeout=CAN_SEND_TIMEOUT_MS):
|
||||
self.can_send_many([[addr, None, dat, bus]], timeout=timeout)
|
||||
|
||||
def can_recv(self):
|
||||
dat = bytearray()
|
||||
|
||||
Reference in New Issue
Block a user