fix cgo build directive
This commit is contained in:
@@ -205,16 +205,23 @@ found:
|
||||
}
|
||||
|
||||
func (d *Device) GetStringDescriptor(desc_index int) (string, error) {
|
||||
|
||||
// allocate 200-byte array limited the length of string descriptor
|
||||
goBuffer := make([]byte, 200)
|
||||
|
||||
// get string descriptor from libusb. if errno < 0 then there are any errors.
|
||||
// if errno >= 0; it is a length of result string descriptor
|
||||
errno := C.libusb_get_string_descriptor_ascii(
|
||||
d.handle,
|
||||
C.uint8_t(desc_index),
|
||||
(*C.uchar)(unsafe.Pointer(&goBuffer[0])),
|
||||
200)
|
||||
|
||||
// if any errors occur
|
||||
if errno < 0 {
|
||||
return "", fmt.Errorf("usb: getstr: %s", usbError(errno))
|
||||
}
|
||||
// convert slice of byte to string with limited length from errno
|
||||
stringDescriptor := string(goBuffer[:errno])
|
||||
|
||||
return stringDescriptor, nil
|
||||
|
@@ -16,8 +16,8 @@
|
||||
package usb
|
||||
|
||||
// #cgo windows CFLAGS: -ID:/lib/libusb-1.0.19/include
|
||||
// #cgo windows amd64 LDFLAGS: D:/lib/libusb-1.0.19/MinGW64/static/libusb-1.0.a
|
||||
// #cgo windows 386 LDFLAGS: D:/lib/libusb-1.0.19/MinGW32/static/libusb-1.0.a
|
||||
// #cgo windows,amd64 LDFLAGS: D:/lib/libusb-1.0.19/MinGW64/static/libusb-1.0.a
|
||||
// #cgo windows,386 LDFLAGS: D:/lib/libusb-1.0.19/MinGW32/static/libusb-1.0.a
|
||||
// #cgo !windows LDFLAGS: -lusb-1.0
|
||||
// #include <libusb-1.0/libusb.h>
|
||||
import "C"
|
||||
|
BIN
usb/usb.test
BIN
usb/usb.test
Binary file not shown.
Reference in New Issue
Block a user