mattscamp / zerousb

The simplest USB library for Go
GNU Lesser General Public License v3.0
6 stars 1 forks source link

failed to get device 4 config 0: libusb: not found [code -5] error message #1

Open kernelPanic0x opened 2 years ago

kernelPanic0x commented 2 years ago

Hi. I am trying to get libusb to run with go but I am stuck and cant get it to work. Tried every port available. Yours too.

// go:build none

package main

import (
    "fmt"
    "strings"

    "github.com/mattscamp/zerousb"
)

func main() {
    // Enumerate over all connected devices
    devices, err := zerousb.Find(0, 0)
    if err != nil {
        panic(err)
    }
    for i, dvc := range devices {
        fmt.Printf("DVC #%d\n", i)
        fmt.Printf("  OS Path:    %s\n", dvc.Path)
        fmt.Printf("  Vendor ID:  %#04x\n", dvc.VendorID)
        fmt.Printf("  Product ID: %#04x\n", dvc.ProductID)
        fmt.Printf("  Interface:  %d\n", dvc.Interface)
        fmt.Println(strings.Repeat("-", 128))
    }
    if len(devices) < 1 {
        panic("No device found.")
    }
    connectedDevice, err := devices[0].Open()
    if err != nil {
        panic(err)
    }
    connectedDevice.Close()
}

If I run the example I get an "failed to get device 4 config 0: libusb: not found [code -5]" error. I think it is an issue with libusb but I am not sure.

Is there anything i can do about it? Seems to be a problem with some USB hubs or so. I have seen similar posts from other people having trouble with libusb and this error message.

kernelPanic0x commented 2 years ago

Small update:

When I debug i get three devices but then the error arises. I have read something about a driver that libusb can't open for a device and then this message gets thrown.

mattscamp commented 2 years ago

Hey @kernelPanic0x ,

Sorry for the late reply, been really busy at work recently. You're failing right here: https://github.com/mattscamp/zerousb/blob/main/libusb.go#L85 when we are retrieving the config descriptor.

Can you log the desc at that point and return it to me? That should help us narrow down your issue.

I am guessing it has something to do with root hubs that have a bNumConfigurations set.

mattscamp commented 2 years ago

@kernelPanic0x - want to follow up with you. I can add an option to "soft error" on these types of errors which should help you bypass the issue. I would still like to see what the actual device erroring out is though.

jkampich1411 commented 2 years ago

I've got the same issue! How would I get to the desc? (Sorry if this doesn't really help but I'm very new to Go development...)

If you need the device description, I've got this from @google/gousb, as I use this for discovering devices because it just works sooo much faster. vid=057e,pid=200e,bus=2,addr=5

Edit: Also I just realised that as soon as I installed this library even the code that doesn't use this library turns to absolute hellfire...

mattscamp commented 2 years ago

I've got the same issue! How would I get to the desc? (Sorry if this doesn't really help but I'm very new to Go development...)

If you need the device description, I've got this from @google/gousb, as I use this for discovering devices because it just works sooo much faster. vid=057e,pid=200e,bus=2,addr=5

Edit: Also I just realised that as soon as I installed this library even the code that doesn't use this library turns to absolute hellfire...

Hey @jkampich1411 ,

Are you trying to Find that specific device by passing the ids instead of 0,0?

If yes, what kind of device is it? If no, can you try that specifying and seeing if that resolves your issue as it would bypass this portion.

Can you expand on the hellfire portion?

jkampich1411 commented 2 years ago

Jup, I'm using specific IDs for Find() which would be the IDs that I sent above.. The device is a JoyCon Charging Grip which offers 2 interfaces for communicating with the JoyCons.

To explain the hellfire portion: Even my code that I wrote using gousb doesn't work after installing this library... It just outputs the libusb [error -5] thing...