Skip to content

Commit

Permalink
Remove retry can_send_many loop (#2060)
Browse files Browse the repository at this point in the history
* remove retry loop from can_send_many

* while condition
  • Loading branch information
lukasloetkolben authored Oct 15, 2024
1 parent abdc418 commit e2c076c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,18 +831,10 @@ def can_reset_communications(self):
@ensure_can_packet_version
def can_send_many(self, arr, timeout=CAN_SEND_TIMEOUT_MS):
snds = pack_can_buffer(arr)
while True:
try:
for tx in snds:
while True:
bs = self._handle.bulkWrite(3, tx, timeout=timeout)
tx = tx[bs:]
if len(tx) == 0:
break
logger.error("CAN: PARTIAL SEND MANY, RETRYING")
break
except (usb1.USBErrorIO, usb1.USBErrorOverflow):
logger.error("CAN: BAD SEND MANY, RETRYING")
for tx in snds:
while len(tx) > 0:
bs = self._handle.bulkWrite(3, tx, timeout=timeout)
tx = tx[bs:]

def can_send(self, addr, dat, bus, timeout=CAN_SEND_TIMEOUT_MS):
self.can_send_many([[addr, dat, bus]], timeout=timeout)
Expand Down

0 comments on commit e2c076c

Please sign in to comment.