hink / go-blink1

Thingm Blink(1) interface library for Go
20 stars 9 forks source link

Blink1 mk3 doesn't seem to be able to open properly #7

Open kazrakcom opened 4 years ago

kazrakcom commented 4 years ago

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.

kazrakcom commented 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().

kazrakcom commented 4 years ago

Attempting to write to a mk3 fails for unclear reasons.

kazrakcom commented 4 years ago

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

todbot commented 4 years ago

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.

todbot commented 4 years ago

I believe I have found the problem. I have submitted PR #8 to address it.

mgumz commented 1 year ago

@kazrakcom yep, @todbot's patch works.