Skip to content

Commit

Permalink
HACK: Sleep between packets.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Apr 16, 2024
1 parent 56b34f1 commit 340b13c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pybricksdev/flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@ async def flash(self, firmware, metadata):
# have a few hacks to special case this. City hub further complicates
# things by having a buggy Bluetooth implementation in its bootloader.
response = await self.bootloader_request(
self.ERASE_FLASH_CITY_HUB
if info.type_id == HubKind.CITY and not platform.system() == "Windows"
else self.ERASE_FLASH,
(
self.ERASE_FLASH_CITY_HUB
if info.type_id == HubKind.CITY
and not platform.system() == "Windows"
else self.ERASE_FLASH
),
timeout=5,
)
logger.debug(response)
Expand Down Expand Up @@ -238,6 +241,7 @@ def reader():
# for this as a hack. This throttles the speed of sending data
# to a rate that can be handled by both the sender and the hub.
if i % 10 == 9:
await asyncio.sleep(0.5)
result = await self.bootloader_request(
self.GET_CHECKSUM, timeout=0.5
)
Expand All @@ -255,6 +259,7 @@ def reader():
data = struct.pack(
f"<BI{len(payload)}B", len(payload) + 4, address, *payload
)
await asyncio.sleep(0.1)
response = await self.bootloader_request(request, data)
logger.debug(response)
pbar.update(len(payload))
Expand Down

0 comments on commit 340b13c

Please sign in to comment.