You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt""github.com/karalabe/hid"
)
funcmain() {
// Ledger Nano S Vendor ID and Product IDvendorID:=uint16(0x2c97)
productID:=uint16(0x1015)
// Enumerate devices to find the Ledgerdevices:=hid.Enumerate(vendorID, productID)
iflen(devices) ==0 {
fmt.Println("No Ledger Nano S found.")
return
}
// Open the first found Ledger devicedevice, err:=devices[0].Open()
iferr!=nil {
fmt.Printf("Failed to open device: %v\n", err)
return
}
deferdevice.Close()
fmt.Println("Device successfully opened.")
}
Output:
Failed to open device: hidapi: failed to open device
While it is possible to open/connect using homebrew's hidapi like this:
package main
/*#cgo CFLAGS: -I/opt/homebrew/Cellar/hidapi/0.14.0/include/hidapi#cgo LDFLAGS: -L/opt/homebrew/Cellar/hidapi/0.14.0/lib -lhidapi#include <hidapi.h>*/import"C"import (
"fmt"
)
funcmain() {
// Initialize the HIDAPI libraryres:=C.hid_init()
ifres!=0 {
fmt.Println("Failed to initialize HIDAPI")
return
}
deferC.hid_exit()
// Open the device using Vendor ID and Product IDvendorID:=C.ushort(0x2c97)
productID:=C.ushort(0x1015)
device:=C.hid_open(vendorID, productID, nil)
ifdevice==nil {
fmt.Println("Failed to open device")
return
}
deferC.hid_close(device)
// Your HID interaction code herefmt.Println("Device opened successfully")
}
Output:
Device opened successfully
The text was updated successfully, but these errors were encountered:
I tried with this minimal test program:
Output:
While it is possible to open/connect using homebrew's hidapi like this:
Output:
The text was updated successfully, but these errors were encountered: