Skip to content

Commit fde6860

Browse files
committed
EV3: Fix flashing on Windows.
Windows requires a reportid byte at the front of each sent message for an HID device, even if the device doesn't use reportids. Adding this synthetic 0x00 to the front of the message enables successful EV3 flashing on Windows.
1 parent a1a9a71 commit fde6860

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pybricksdev/connections/ev3.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,17 @@ def _send_command(self, command: Command, payload: bytes | None = None) -> int:
8484

8585
length += len(payload)
8686

87+
# report_id is not used by the EV3 but is required by HIDAPI on Windows.
88+
# It does no harm on Linux, so we include it unconditionally. Note that
89+
# the report ID is automatically stripped from incoming messages by
90+
# HIDAPI on all platforms.
91+
report_id = 0
92+
8793
message_number = next(self._msg_count)
8894

8995
message = struct.pack(
90-
"<HHBB",
96+
"<BHHBB",
97+
report_id,
9198
length,
9299
message_number,
93100
MessageType.SYSTEM_COMMAND_REPLY,

0 commit comments

Comments
 (0)