Skip to content

Commit c222023

Browse files
authored
connections.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 f87d27b commit c222023

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
### Fixed
1414
- Fixed compiling multi-file projects with implicit namespace packages.
15+
- Fixed EV3 firmware upload on Windows ([pybricksdev#128]).
16+
17+
[pybricksdev#128]: https://github.com/pybricks/pybricksdev/pull/128
1518

1619
## [2.3.0] - 2025-10-31
1720

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)