go-blink1 icon indicating copy to clipboard operation
go-blink1 copied to clipboard

panic: Unable to write to blink(1)

Open 6UzoTE opened this issue 1 year ago • 5 comments

On Ubuntu Ubuntu 22.04.1 LTS (x86_64) I get the err "panic: Unable to write to blink(1)". Building the tool worked fine. Blink works well with blink1-tool

Any idea were I could investigate ?

6UzoTE avatar Dec 13 '22 19:12 6UzoTE

Are you using sudo for blink1-tool or do you have the udev rules installed?

todbot avatar Dec 13 '22 19:12 todbot

Very fast reply. Thank you. udev rules are installed as per instructions: https://github.com/todbot/blink1-tool

6UzoTE avatar Dec 13 '22 19:12 6UzoTE

Hmm, well I tried the simple example on the README on my Ubuntu 22 x86 box and while it doesn't panic, it also doesn't seem to actually do anything. Unfortunately, I don't know much about Go, so I can't really help.

This library does seem to be using the much older libusb-0.1 API instead of the current libusb-1.0 API. Also in general on Linux, it's better to use the hidraw API instead of libusb.

It looks like there is a (Go wrapper on hidapi](https://pkg.go.dev/github.com/karalabe/hid), which would be the preferred way of interfacing with blink(1), or any HID device.

As a work-around, I recommend creating a function that abstracts away your blink(1) calls and for now uses the blink1-tool command-line program like:

package main
import "fmt"
import "os/exec"

func main() {
    stdout,err := exec.Command("blink1-tool", "--rgb", "FF00FF").Output()
    if err != nil {
        fmt.Println(err.Error())
        return
    }
    fmt.Print(string(stdout))
}

todbot avatar Dec 13 '22 20:12 todbot

Thank you. Compiled the program. Ran it. blink turns purple. Output: set dev:0:0 to rgb:0xff,0x00,0xff over 300 msec Use go-blink test program and still err "panic: Unable to write to blink(1)"

6UzoTE avatar Dec 14 '22 19:12 6UzoTE

As a work-around, I recommend creating a function that abstracts away your blink(1) calls and for now uses the blink1-tool command-line program like:

This is how I do it today. I wanted to get rid of using ugly exec calls.

6UzoTE avatar Dec 14 '22 20:12 6UzoTE