Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: Unable to write to blink(1) #9

Open
6UzoTE opened this issue Dec 13, 2022 · 5 comments
Open

panic: Unable to write to blink(1) #9

6UzoTE opened this issue Dec 13, 2022 · 5 comments

Comments

@6UzoTE
Copy link

6UzoTE commented Dec 13, 2022

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 ?

@todbot
Copy link

todbot commented Dec 13, 2022

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

@6UzoTE
Copy link
Author

6UzoTE commented Dec 13, 2022

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

@todbot
Copy link

todbot commented Dec 13, 2022

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))
}

@6UzoTE
Copy link
Author

6UzoTE commented Dec 14, 2022

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
Copy link
Author

6UzoTE commented Dec 14, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants