Fix ordering of config
This commit is contained in:
@@ -5,7 +5,6 @@ import "C"
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -159,6 +158,11 @@ func (d *Device) OpenEndpoint(conf, iface, setup, epoint uint8) (Endpoint, error
|
|||||||
|
|
||||||
found:
|
found:
|
||||||
|
|
||||||
|
// Set the configuration
|
||||||
|
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
|
||||||
if errno := C.libusb_claim_interface(d.handle, C.int(iface)); errno < 0 {
|
if errno := C.libusb_claim_interface(d.handle, C.int(iface)); errno < 0 {
|
||||||
return nil, fmt.Errorf("usb: claim: %s", usbError(errno))
|
return nil, fmt.Errorf("usb: claim: %s", usbError(errno))
|
||||||
@@ -169,16 +173,11 @@ found:
|
|||||||
d.claimed[iface]++
|
d.claimed[iface]++
|
||||||
d.lock.Unlock() // unlock immediately because the next calls may block
|
d.lock.Unlock() // unlock immediately because the next calls may block
|
||||||
|
|
||||||
// Set the configuration
|
|
||||||
if errno := C.libusb_set_configuration(d.handle, C.int(conf)); errno < 0 {
|
|
||||||
return nil, fmt.Errorf("usb: setcfg: %s", usbError(errno))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Choose the alternate
|
// Choose the alternate
|
||||||
// This doesn't seem to work...
|
// This doesn't seem to work...
|
||||||
if errno := C.libusb_set_interface_alt_setting(d.handle, C.int(iface), C.int(setup)); errno < 0 {
|
if errno := C.libusb_set_interface_alt_setting(d.handle, C.int(iface), C.int(setup)); errno < 0 {
|
||||||
log.Printf("ignoring altsetting error: %s", usbError(errno))
|
//log.Printf("ignoring altsetting error: %s", usbError(errno))
|
||||||
//return nil, fmt.Errorf("usb: setalt: %s", usbError(errno))
|
return nil, fmt.Errorf("usb: setalt: %s", usbError(errno))
|
||||||
}
|
}
|
||||||
|
|
||||||
return end, nil
|
return end, nil
|
||||||
|
@@ -26,7 +26,7 @@ func (end *endpoint) allocTransfer() *Transfer {
|
|||||||
// Use libusb_get_max_iso_packet_size ?
|
// Use libusb_get_max_iso_packet_size ?
|
||||||
const (
|
const (
|
||||||
iso_packets = 8 // 128 // 242
|
iso_packets = 8 // 128 // 242
|
||||||
packet_size = 2048 // 1760
|
packet_size = 2*960 // 1760
|
||||||
)
|
)
|
||||||
|
|
||||||
xfer := C.libusb_alloc_transfer(C.int(iso_packets))
|
xfer := C.libusb_alloc_transfer(C.int(iso_packets))
|
||||||
|
Reference in New Issue
Block a user