Hello,

I'm trying to do some bulk IO with a custom USB device on OSX and fail 
miserably. This is the small source code which just tries to write a few 
bytes to a bulk endpoint:

#include <stdio.h>
#include <libusb-1.0/libusb.h>

int main()
{
     libusb_context *ctx;
     libusb_device_handle *handle;

     libusb_init(&ctx);
     libusb_set_debug(ctx, 3);
     handle = libusb_open_device_with_vid_pid(ctx, 0x16c0, 0x05dc);
     libusb_set_configuration(handle, 1);
     libusb_claim_interface(handle, 0);

     unsigned char *write_data = "\1Test\0";
     int written;
     if (libusb_bulk_transfer(handle, 0x04, write_data, 6, &written, 2000))
     {
         printf("write failed\n");
         return 1;
     }
     printf("%i bytes written\n", written);

     libusb_release_interface(handle, 0);
     libusb_close(handle);
     libusb_exit(ctx);
     return 0;
}

The program runs fine on Linux but when I try it on OSX (with the same 
USB device) then the libusb_bulk_transfer call fails with 
LIBUSB_ERROR_PIPE and the following debug messages:

[00000707] libusbx: debug [darwin_open] device open for access
[00000707] libusbx: debug [libusb_set_configuration] configuration 1
[00000707] libusbx: debug [libusb_claim_interface] interface 0
[00000707] libusbx: debug [get_endpoints] building table of endpoints.
[00000707] libusbx: debug [get_endpoints] interface: 0 pipe 1: dir: 1 
number: 4
[00000707] libusbx: debug [get_endpoints] interface: 0 pipe 2: dir: 0 
number: 4
[00000707] libusbx: debug [darwin_claim_interface] interface opened
[00000707] libusbx: debug [ep_to_pipeRef] converting ep address 0x04 to 
pipeRef and interface
[00000707] libusbx: debug [ep_to_pipeRef] pipe 2 on interface 0 matches
[00000707] libusbx: debug [libusb_get_next_timeout] no URB with timeout 
or all handled by OS; no timeout!
[00000707] libusbx: debug [libusb_handle_events_timeout_completed] doing 
our own event handling
[00000707] libusbx: debug [handle_events] poll() 2 fds with timeout in 
60000ms
[00001607] libusbx: debug [darwin_async_io_callback] an async io 
operation has completed
[00000707] libusbx: debug [handle_events] poll() returned 1
[00000707] libusbx: debug [op_handle_events] checking fd 4 with revents = 0
[00000707] libusbx: debug [op_handle_events] checking fd 6 with revents = 1
[00000707] libusbx: debug [darwin_handle_callback] handling bulk 
completion with kernel status -536854449
[00000707] libusbx: debug [darwin_transfer_status] transfer error: pipe 
is stalled
[00000707] libusbx: debug [usbi_handle_transfer_completion] transfer 
0x7ff89a4099f0 has callback 0x10a889190
[ 0.557680] [00000707] libusbx: debug [bulk_transfer_cb] actual_length=0

I'm confused. If I'm doing something wrong here or when the USB device 
is doing something wrong then why does it work on Linux? Is there 
anything wrong in my code which can cause this error only on OSX? On OSX 
I'm using libusbx-1.0.14 while on Linux I'm using the libusb package 
shipped with Ubuntu (libusbx-1.0.12).

Any help is highly appreciated.

-- 
Bye, K <http://www.ailis.de/~k/>
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]

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

Reply via email to