Skip to content

Commit c880081

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 c880081

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pybricksdev/connections/ev3.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import asyncio
55
import enum
66
import itertools
7+
import platform
78
import struct
89
from typing import Callable
910

@@ -84,10 +85,17 @@ def _send_command(self, command: Command, payload: bytes | None = None) -> int:
8485

8586
length += len(payload)
8687

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

8996
message = struct.pack(
90-
"<HHBB",
97+
"<BHHBB",
98+
report_id,
9199
length,
92100
message_number,
93101
MessageType.SYSTEM_COMMAND_REPLY,

0 commit comments

Comments
 (0)