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

Couldn't open Ledger nano S on Mac Sonoma (chip M1 max) #53

Closed
tranvictor opened this issue Apr 22, 2024 · 1 comment
Closed

Couldn't open Ledger nano S on Mac Sonoma (chip M1 max) #53

tranvictor opened this issue Apr 22, 2024 · 1 comment

Comments

@tranvictor
Copy link

tranvictor commented Apr 22, 2024

I tried with this minimal test program:

package main

import (
	"fmt"

	"github.com/karalabe/hid"
)

func main() {
	// Ledger Nano S Vendor ID and Product ID
	vendorID := uint16(0x2c97)
	productID := uint16(0x1015)

	// Enumerate devices to find the Ledger
	devices := hid.Enumerate(vendorID, productID)
	if len(devices) == 0 {
		fmt.Println("No Ledger Nano S found.")
		return
	}

	// Open the first found Ledger device
	device, err := devices[0].Open()
	if err != nil {
		fmt.Printf("Failed to open device: %v\n", err)
		return
	}
	defer device.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"
)

func main() {
	// Initialize the HIDAPI library
	res := C.hid_init()
	if res != 0 {
		fmt.Println("Failed to initialize HIDAPI")
		return
	}
	defer C.hid_exit()

	// Open the device using Vendor ID and Product ID
	vendorID := C.ushort(0x2c97)
	productID := C.ushort(0x1015)
	device := C.hid_open(vendorID, productID, nil)
	if device == nil {
		fmt.Println("Failed to open device")
		return
	}
	defer C.hid_close(device)

	// Your HID interaction code here
	fmt.Println("Device opened successfully")
}

Output:

Device opened successfully
@tranvictor
Copy link
Author

Looks like this issue is fixed already with master. Closing this.

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

1 participant