-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Hi
Here, the report ID is prepended, but only for Windows:
Lines 126 to 128 in 87927bb
if runtime.GOOS == "windows" { | |
report = append([]byte{0x00}, b...) | |
} else { |
The same issue exists in the hid repo, where I commented about the same issue in 2018: karalabe/hid#7 (comment)
Since the first byte after the report ID can legitimately be a zero byte (a USB packet that starts with a zero byte), this code is broken on linux/macOS, where one has to manually prepend that zero byte report ID. Without prepending the zero byte report ID for linux/macOS, the lower level library will strip the the first byte if it is zero (see below), corrupting the packet:
Lines 1003 to 1007 in 87927bb
if (report_number == 0x0) { | |
data++; | |
length--; | |
skipped_report_id = 1; | |
} |
This is a hard issue to find, as it can be a rare event that a packet starts with a zero byte (after the report ID).
See e.g. this PR which implements this workaround: https://github.com/digitalbitbox/bitbox02-api-go/pull/73/files