On Tue, Mar 5, 2013 at 8:27 AM, Pete Batard <p...@akeo.ie> wrote: > On 2013.03.03 14:45, Xiaofan Chen wrote: >> Indeed it works better when going back to older version. Still that >> older version failed to get the Extended Properties OS Feature Descriptor. > > Have you tried using os_fd[i].recipient for both requests? Simply > reverting the patch will not do, as there is still an extra fix needed. > > If you just revert, then the first request (header) for Ext Props will > still be forced as LIBUSB_RECIPIENT_DEVICE, and is therefore expected to > fail with the Microchip stack, as only the second full request is set to > LIBUSB_RECIPIENT_INTERFACE (We have 4 requests in all, with one for > header, and one for full data for each of Compat ID and Ext Props). > > For Extended Compat ID, this isn't an issue as os_fd[i] is set to > LIBUSB_RECIPIENT_DEVICE, so the first and second request match regardless. > > In other words, you want to have: > r = libusb_control_transfer(handle, > (uint8_t)(LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|os_fd[i].recipient), > for both requests. > > If you confirm that this works, I'll revert the patch, with this extra > change applied, and push it. >
It is kind of strange under Mac OS X. I can not get it to work with the current git. mymacmini:libusbx xiaofanc$ git diff diff --git a/examples/xusb.c b/examples/xusb.c index 1aa3363..795298c 100644 --- a/examples/xusb.c +++ b/examples/xusb.c @@ -679,7 +679,7 @@ static int test_hid(libusb_device_handle *handle, uint8_t endpoint_in) } // Read the MS WinUSB Feature Descriptors, that are used on Windows 8 for automated driver installation -static void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uint8_t bRequest, int iface_number) +void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uint8_t bRequest, int iface_number) { #define MAX_OS_FD_LENGTH 256 int i, r; @@ -688,11 +688,12 @@ static void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uin void* le_type_punning_IS_fine; struct { const char* desc; + uint8_t recipient; uint16_t index; uint16_t header_size; } os_fd[2] = { - {"Extended Compat ID", 0x0004, 0x10}, - {"Extended Properties", 0x0005, 0x0A} + {"Extended Compat ID", LIBUSB_RECIPIENT_DEVICE, 0x0004, 0x10}, + {"Extended Properties", LIBUSB_RECIPIENT_INTERFACE, 0x0005, 0x0A} }; if (iface_number < 0) return; @@ -701,7 +702,7 @@ static void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uin printf("\nReading %s OS Feature Descriptor (wIndex = 0x%04d):\n", os_fd[i].desc, os_fd[i].index); // Read the header part - r = libusb_control_transfer(handle, (uint8_t)(LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|LIBUSB_RECIPIENT_DEVICE), + r = libusb_control_transfer(handle, (uint8_t)(LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|os_fd[i].recipient), bRequest, (uint16_t)(((iface_number)<< 8)|0x00), os_fd[i].index, os_desc, os_fd[i].header_size, 1000); if (r < os_fd[i].header_size) { perr(" Failed: %s", (r<0)?libusb_error_name((enum libusb_error)r):"header size is too small"); @@ -714,7 +715,7 @@ static void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uin } // Read the full feature descriptor - r = libusb_control_transfer(handle, (uint8_t)(LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|LIBUSB_RECIPIENT_DEVICE), + r = libusb_control_transfer(handle, (uint8_t)(LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|os_fd[i].recipient), bRequest, (uint16_t)(((iface_number)<< 8)|0x00), os_fd[i].index, os_desc, (uint16_t)length, 1000); if (r < 0) { perr(" Failed: %s", libusb_error_name((enum libusb_error)r)); (END) mymacmini:libusbx xiaofanc$ ./examples/xusb 04d8:0053 Using libusbx v1.0.14.10622 Opening device 04D8:0053... Reading device descriptor: length: 18 device class: 0 S/N: 0 VID:PID: 04D8:0053 bcdDevice: 0000 iMan:iProd:iSer: 1:2:0 nb confs: 1 Reading configuration descriptors: nb interfaces: 1 interface[0]: id = 0 interface[0].altsetting[0]: num endpoints = 2 Class.SubClass.Protocol: FF.FF.FF endpoint[0].address: 01 max packet size: 0040 polling interval: 01 endpoint[1].address: 81 max packet size: 0040 polling interval: 01 Claiming interface 0... Reading string descriptors: String (0x01): "Microchip Technology Inc." String (0x02): "Microchip WinUSB Example Device" String (0xEE): "MSFT100?" Reading Extended Compat ID OS Feature Descriptor (wIndex = 0x0004): Failed: LIBUSB_ERROR_PIPE Releasing interface 0... Closing device... Reading Extended Compat ID OS Feature Descriptor (wIndex = 0x0004): [ 0.116589] [00000e07] libusbx: debug [libusb_get_next_timeout] no URB with timeout or all handled by OS; no timeout! [ 0.116604] [00000e07] libusbx: debug [libusb_handle_events_timeout_completed] doing our own event handling [ 0.116617] [00000e07] libusbx: debug [handle_events] poll() 2 fds with timeout in 60000ms [ 0.116784] [00001707] libusbx: debug [darwin_async_io_callback] an async io operation has completed [ 0.116816] [00000e07] libusbx: debug [handle_events] poll() returned 1 [ 0.116829] [00000e07] libusbx: debug [op_handle_events] checking fd 4 with revents = 0 [ 0.116836] [00000e07] libusbx: debug [op_handle_events] checking fd 6 with revents = 1 [ 0.116851] [00000e07] libusbx: debug [darwin_handle_callback] handling control completion with kernel status -536854449 [ 0.116864] [00000e07] libusbx: debug [darwin_transfer_status] transfer error: pipe is stalled [ 0.116876] [00000e07] libusbx: debug [usbi_handle_transfer_completion] transfer 0x7fbb38c01720 has callback 0x10a5ef200 [ 0.116888] [00000e07] libusbx: debug [ctrl_transfer_cb] actual_length=0 Failed: LIBUSB_ERROR_PIPE For the old libusb.org libusb-pbatard, it is actually working after changing one line for the Extended Properties OS Feature Descriptor. mymacmini:libusb-pbatard xiaofanc$ ./examples/xusb 04d8:0053 Using libusb v1.0.8.10349 Opening device... bus: 250, port path from HCD: 1 speed: 12 Mbit/s (USB 1.0 FullSpeed) Reading device descriptor: length: 18 device class: 0 S/N: 0 VID:PID: 04D8:0053 bcdDevice: 0000 iMan:iProd:iSer: 1:2:0 nb confs: 1 Reading configuration descriptors: nb interfaces: 1 interface[0]: id = 0 interface[0].altsetting[0]: num endpoints = 2 Class.SubClass.Protocol: FF.FF.FF endpoint[0].address: 01 max packet size: 0040 polling interval: 01 endpoint[1].address: 81 max packet size: 0040 polling interval: 01 Claiming interface 0... Reading string descriptors: String (0x01): "Microchip Technology Inc." String (0x02): "Microchip WinUSB Example Device" String (0xEE): "MSFT100?" Reading Extended Compat ID OS Feature Descriptor (wIndex = 0x0004): 00000000 28 00 00 00 00 01 04 00 01 00 00 00 00 00 00 00 (............... 00000010 00 01 57 49 4e 55 53 42 00 00 00 00 00 00 00 00 ..WINUSB........ 00000020 00 00 00 00 00 00 00 00 ........ Reading Extended Properties OS Feature Descriptor (wIndex = 0x0005): 00000000 8e 00 00 00 00 01 05 00 01 00 84 00 00 00 01 00 ................ 00000010 00 00 28 00 44 00 65 00 76 00 69 00 63 00 65 00 ..(.D.e.v.i.c.e. 00000020 49 00 6e 00 74 00 65 00 72 00 66 00 61 00 63 00 I.n.t.e.r.f.a.c. 00000030 65 00 47 00 55 00 49 00 44 00 00 00 4e 00 00 00 e.G.U.I.D...N... 00000040 7b 00 35 00 38 00 64 00 30 00 37 00 32 00 31 00 {.5.8.d.0.7.2.1. 00000050 30 00 2d 00 32 00 37 00 63 00 31 00 2d 00 31 00 0.-.2.7.c.1.-.1. 00000060 31 00 64 00 64 00 2d 00 62 00 64 00 30 00 62 00 1.d.d.-.b.d.0.b. 00000070 2d 00 30 00 38 00 30 00 30 00 32 00 30 00 30 00 -.0.8.0.0.2.0.0. 00000080 63 00 39 00 61 00 36 00 36 00 7d 00 00 00 c.9.a.6.6.}... Releasing interface 0... Closing device... mymacmini:libusb-pbatard xiaofanc$ git diff diff --git a/configure.ac b/configure.ac index f983e48..9b98cec 100644 --- a/configure.ac +++ b/configure.ac @@ -32,7 +32,7 @@ AM_MAINTAINER_MODE AC_CONFIG_SRCDIR([libusb/core.c]) AC_CONFIG_MACRO_DIR([m4]) -AM_CONFIG_HEADER([config.h]) +AC_CONFIG_HEADERS([config.h]) # Enable silent build rules by default (Automake v1.11 or later). # Disable by either passing --disable-silent-rules to configure or passing V=1 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], diff --git a/examples/Makefile.am b/examples/Makefile.am index e8a4516..4a20dca 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -2,14 +2,14 @@ INCLUDES = -I$(top_srcdir)/libusb noinst_PROGRAMS = xusb lsusb lsusb_SOURCES = lsusb.c -lsusb_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +lsusb_LDADD = ../libusb/libusb-1.0.la xusb_SOURCES = xusb.c -xusb_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +xusb_LDADD = ../libusb/libusb-1.0.la if HAVE_SIGACTION dpfp_SOURCES = dpfp.c -dpfp_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +dpfp_LDADD = ../libusb/libusb-1.0.la noinst_PROGRAMS += dpfp endif @@ -17,7 +17,7 @@ if THREADS_POSIX if HAVE_SIGACTION dpfp_threaded_SOURCES = dpfp_threaded.c dpfp_threaded_CFLAGS = $(THREAD_CFLAGS) $(AM_CFLAGS) -dpfp_threaded_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +dpfp_threaded_LDADD = ../libusb/libusb-1.0.la noinst_PROGRAMS += dpfp_threaded endif endif diff --git a/examples/xusb.c b/examples/xusb.c index db50280..f07b15d 100644 --- a/examples/xusb.c +++ b/examples/xusb.c @@ -541,12 +541,7 @@ void read_ms_winsub_feature_descriptors(libusb_device_handl uint16_t header_size; } os_fd[2] = { {"Extended Compat ID", LIBUSB_RECIPIENT_DEVICE, 0x0004, 0x10}, - {"Extended Properties", LIBUSB_RECIPIENT_DEVICE, 0x0005, 0x0A} - // NB: LIBUSB_RECIPIENT_INTERFACE should be used for the Extende - // However, for Interface requests, the WinUSB DLL forces the lo - // to the interface number, regardless of what you set it to, so - // fallback to Device and hope the firmware answers both equally - // See http://www.lvr.com/forum/index.php?topic=331 + {"Extended Properties", LIBUSB_RECIPIENT_INTERFACE, 0x0005, 0x0A }; if (iface_number < 0) return; -- Xiaofan ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel