Merge pull request #5 from krasin/fix-multiple-endpoints

Allow opening multiple endpoints for the same device
This commit is contained in:
Kyle Lemons
2013-06-18 00:42:02 -07:00

View File

@@ -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