Merge branch 'master' of github.com:kylelemons/gousb
This commit is contained in:
@@ -147,3 +147,23 @@ var isoUsageTypeDescription = map[IsoUsageType]string{
|
|||||||
func (iut IsoUsageType) String() string {
|
func (iut IsoUsageType) String() string {
|
||||||
return isoUsageTypeDescription[iut]
|
return isoUsageTypeDescription[iut]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RequestType uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
REQUEST_TYPE_STANDARD = C.LIBUSB_REQUEST_TYPE_STANDARD
|
||||||
|
REQUEST_TYPE_CLASS = C.LIBUSB_REQUEST_TYPE_CLASS
|
||||||
|
REQUEST_TYPE_VENDOR = C.LIBUSB_REQUEST_TYPE_VENDOR
|
||||||
|
REQUEST_TYPE_RESERVED = C.LIBUSB_REQUEST_TYPE_RESERVED
|
||||||
|
)
|
||||||
|
|
||||||
|
var requestTypeDescription = map[RequestType]string{
|
||||||
|
REQUEST_TYPE_STANDARD: "standard",
|
||||||
|
REQUEST_TYPE_CLASS: "class",
|
||||||
|
REQUEST_TYPE_VENDOR: "vendor",
|
||||||
|
REQUEST_TYPE_RESERVED: "reserved",
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rt RequestType) String() string {
|
||||||
|
return requestTypeDescription[rt]
|
||||||
|
}
|
||||||
|
@@ -157,8 +157,14 @@ func (d *Device) OpenEndpoint(conf, iface, setup, epoint uint8) (Endpoint, error
|
|||||||
found:
|
found:
|
||||||
|
|
||||||
// Set the configuration
|
// Set the configuration
|
||||||
if errno := C.libusb_set_configuration(d.handle, C.int(conf)); errno < 0 {
|
var activeConf C.int
|
||||||
return nil, fmt.Errorf("usb: setcfg: %s", usbError(errno))
|
if errno := C.libusb_get_configuration(d.handle, &activeConf); errno < 0 {
|
||||||
|
return nil, fmt.Errorf("usb: getcfg: %s", usbError(errno))
|
||||||
|
}
|
||||||
|
if int(activeConf) != int(conf) {
|
||||||
|
if errno := C.libusb_set_configuration(d.handle, C.int(conf)); errno < 0 {
|
||||||
|
return nil, fmt.Errorf("usb: setcfg: %s", usbError(errno))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Claim the interface
|
// Claim the interface
|
||||||
|
Reference in New Issue
Block a user