From 7de40963dfb1c037c180d38b4b47c0e798626344 Mon Sep 17 00:00:00 2001 From: lukasloetkolben <61192133+lukasloetkolben@users.noreply.github.com> Date: Fri, 4 Oct 2024 16:49:01 -0700 Subject: [PATCH 1/2] remove retry loop from can_send_many --- python/__init__.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/python/__init__.py b/python/__init__.py index 7da3648e2a..e996e66f76 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -831,18 +831,13 @@ 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 True: + bs = self._handle.bulkWrite(3, tx, timeout=timeout) + tx = tx[bs:] + if len(tx) == 0: + break + logger.error("CAN: PARTIAL SEND MANY, RETRYING") def can_send(self, addr, dat, bus, timeout=CAN_SEND_TIMEOUT_MS): self.can_send_many([[addr, dat, bus]], timeout=timeout) From d4b23dbc54a4abf743c0afc0396180fae84d9f64 Mon Sep 17 00:00:00 2001 From: lukasloetkolben <61192133+lukasloetkolben@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:17:01 -0700 Subject: [PATCH 2/2] while condition --- python/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/python/__init__.py b/python/__init__.py index e996e66f76..0cbf1ef94b 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -832,12 +832,9 @@ def can_reset_communications(self): def can_send_many(self, arr, timeout=CAN_SEND_TIMEOUT_MS): snds = pack_can_buffer(arr) for tx in snds: - while True: + while len(tx) > 0: bs = self._handle.bulkWrite(3, tx, timeout=timeout) tx = tx[bs:] - if len(tx) == 0: - break - logger.error("CAN: PARTIAL SEND MANY, RETRYING") def can_send(self, addr, dat, bus, timeout=CAN_SEND_TIMEOUT_MS): self.can_send_many([[addr, dat, bus]], timeout=timeout)