Open kazrakcom opened 4 years ago
Okay. Marking as closed; mk3 handles reopening differently, but it's my fault. One must explicitly Close() before it can be found with OpenNextDevice().
Attempting to write to a mk3 fails for unclear reasons.
package main
import ( blink1 "github.com/hink/go-blink1" )
func main() { device, err := blink1.OpenNextDevice() if err != nil { panic(err) } err = device.SetState(blink1.State{Red: 255}) if err != nil { panic(err) } }
Works fine on a mk2, running on a mk3 gives:
panic: Unable to write to blink(1)
goroutine 1 [running]: main.main() [path]/test.go:14 +0x87 exit status 2
Could the problem be that at line:
https://github.com/hink/go-blink1/blob/master/libusb/blink1.go#L19
That first byte is the reportId and it should be 1
instead of 0
. I believe blink(1) mk1 and mk2 devices did not explicitly check the reportId but mk3 devices do because it supports two different reports.
I believe I have found the problem. I have submitted PR #8 to address it.
@kazrakcom yep, @todbot's patch works.
Attempting to open a mk3 seems to fail with "all devices busy".
Tossing some logging into OpenNextDevice, it appears that openDevices[dev.Device] is not nil even for a freshly-inserted mk3. I see "&{0xc00009b3e0 100ms {0 0 0 0 0s 10ms}}" as the value there.
I'm investigating further, but logging this here for reference.