From f0d7bb7f9c189de2c22af9eb7210487ed5695f58 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Mon, 25 Apr 2022 17:17:19 -0400 Subject: [PATCH] flash_can: add retries to verification Signed-off-by: Eric Callahan --- scripts/flash_can.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/flash_can.py b/scripts/flash_can.py index c1125d4..2b2facf 100755 --- a/scripts/flash_can.py +++ b/scripts/flash_can.py @@ -158,11 +158,16 @@ class CanFlasher: if resp == i: # command should ack with the requested block as # parameter - buf = await self.node.readexactly( - self.block_size, timeout=10. - ) - if len(buf) == self.block_size: - break + try: + buf = await self.node.readexactly( + self.block_size, timeout=5. + ) + except asyncio.TimeoutError: + if tries: + output_line("\nRead Timeout, Retrying...") + else: + if len(buf) == self.block_size: + break tries -= 1 await asyncio.sleep(.1) else: