From 96ca30cdbb4a47e66f54a8bb4887d771289807bc Mon Sep 17 00:00:00 2001 From: Kyle Lemons Date: Sun, 15 Apr 2012 22:43:55 -0400 Subject: [PATCH] Fix ordering of config --- usb/device.go | 15 +++++++-------- usb/iso.go | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/usb/device.go b/usb/device.go index 11332d4..5a7b8be 100644 --- a/usb/device.go +++ b/usb/device.go @@ -5,7 +5,6 @@ import "C" import ( "fmt" - "log" "reflect" "runtime" "sync" @@ -159,6 +158,11 @@ func (d *Device) OpenEndpoint(conf, iface, setup, epoint uint8) (Endpoint, error 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 if errno := C.libusb_claim_interface(d.handle, C.int(iface)); errno < 0 { return nil, fmt.Errorf("usb: claim: %s", usbError(errno)) @@ -169,16 +173,11 @@ found: d.claimed[iface]++ 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 // This doesn't seem to work... 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)) - //return nil, fmt.Errorf("usb: setalt: %s", usbError(errno)) + //log.Printf("ignoring altsetting error: %s", usbError(errno)) + return nil, fmt.Errorf("usb: setalt: %s", usbError(errno)) } return end, nil diff --git a/usb/iso.go b/usb/iso.go index 639872c..eda5e53 100644 --- a/usb/iso.go +++ b/usb/iso.go @@ -26,7 +26,7 @@ func (end *endpoint) allocTransfer() *Transfer { // Use libusb_get_max_iso_packet_size ? const ( iso_packets = 8 // 128 // 242 - packet_size = 2048 // 1760 + packet_size = 2*960 // 1760 ) xfer := C.libusb_alloc_transfer(C.int(iso_packets))