Skip to content

Commit

Permalink
feat: add distinct usb error
Browse files Browse the repository at this point in the history
  • Loading branch information
Örjan Fors committed Aug 28, 2024
1 parent 6e459cb commit 0593c8d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/atecc/hal_hid.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ import (
"github.com/karalabe/usb"
)

// ErrUSBNotSupported is returned when the USB support is missing.
//
// When building, CGO is required for USB support. If CGO is not enabled, the
// HID interface will not be available.
var ErrUSBNotSupported = errors.New("atecc: usb support is missing")

// NewHIDDev returns an object that communicates over HID.
func NewHIDDev(ctx context.Context, cfg IfaceConfig) (*Dev, io.Closer, error) {
if !usb.Supported() {
return nil, nil, errors.New("atecc: hid is not supported")
return nil, nil, ErrUSBNotSupported
}

deviceInfos, err := usb.EnumerateHid(cfg.HID.VendorID, cfg.HID.ProductID)
Expand Down

0 comments on commit 0593c8d

Please sign in to comment.