flash_can: attempt to reset the mcu if an error is encountered

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-04-26 10:37:49 -04:00
parent c5163674ed
commit 95e8a707ca
No known key found for this signature in database
GPG Key ID: 7027245FBBDDF59A

View File

@ -165,6 +165,11 @@ class CanFlasher:
)
except asyncio.TimeoutError:
if tries:
# clear the read buffer
try:
await self.node.read(2048, timeout=.1)
except asyncio.TimeoutError:
pass
output_line("\nRead Timeout, Retrying...")
else:
if len(buf) == self.block_size:
@ -383,10 +388,15 @@ class CanSocket:
node = self._set_node_id(uuid)
flasher = CanFlasher(node, fw_path)
await asyncio.sleep(.5)
await flasher.connect_btl()
await flasher.send_file()
await flasher.verify_file()
await flasher.finish()
try:
await flasher.connect_btl()
await flasher.send_file()
await flasher.verify_file()
finally:
# always attempt to send the complete command. If
# there is an error it will exit the bootloader
# unless comms were broken
await flasher.finish()
async def run_query(self, intf: str):
try: