Skip to content

Commit 41254b5

Browse files
committed
cli.oad: handle CRC error
Also a few other minor improvements while touching this.
1 parent fc67c1b commit 41254b5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pybricksdev/cli/oad.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,19 @@ async def flash_oad_image(firmware: BinaryIO) -> None:
119119

120120
elif status == OADReturn.DL_COMPLETE:
121121
break
122+
elif status == OADReturn.CRC_ERR:
123+
raise RuntimeError("Failed CRC check")
122124
else:
123-
print(
125+
raise RuntimeError(
124126
f"Block {block_num} with unhandled status: {status.name}"
125127
)
126128
except BaseException:
127129
await control_point.cancel_oad()
128130
raise
129131

130-
# This causes hub to reset and disconnect
131-
await control_point.enable_oad_image()
132+
# This causes hub to reset and disconnect
133+
await control_point.enable_oad_image()
134+
print("Done.")
132135

133136

134137
async def dump_oad_info():

0 commit comments

Comments
 (0)