Skip to content

Commit

Permalink
cli.oad: handle CRC error
Browse files Browse the repository at this point in the history
Also a few other minor improvements while touching this.
  • Loading branch information
dlech committed Aug 9, 2024
1 parent fc67c1b commit 41254b5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pybricksdev/cli/oad.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,19 @@ async def flash_oad_image(firmware: BinaryIO) -> None:

elif status == OADReturn.DL_COMPLETE:
break
elif status == OADReturn.CRC_ERR:
raise RuntimeError("Failed CRC check")
else:
print(
raise RuntimeError(
f"Block {block_num} with unhandled status: {status.name}"
)
except BaseException:
await control_point.cancel_oad()
raise

# This causes hub to reset and disconnect
await control_point.enable_oad_image()
# This causes hub to reset and disconnect
await control_point.enable_oad_image()
print("Done.")


async def dump_oad_info():
Expand Down

0 comments on commit 41254b5

Please sign in to comment.