|
From: XXXXXXXXXXXXXXXXXXXXXXXXX - 2013-02-27 15:54:45
|
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:
libusb: 0.533303 info [darwin_open] device open for access
libusb: 0.551238 info [get_endpoints] building table of endpoints.
libusb: 0.551277 info [get_endpoints] interface: 0 pipe 1: dir: 1 number: 4
libusb: 0.551287 info [get_endpoints] interface: 0 pipe 2: dir: 0 number: 4
libusb: 0.551323 info [darwin_claim_interface] interface opened
libusb: 0.551339 info [ep_to_pipeRef] converting ep address 0x04 to
pipeRef and interface
libusb: 0.551344 info [ep_to_pipeRef] pipe 2 on interface 0 matches
libusb: 0.551495 info [darwin_async_io_callback] an async io operation
has completed
libusb: 0.551527 info [op_handle_events] checking fd 4 with revents = 0
libusb: 0.551535 info [op_handle_events] checking fd 6 with revents = 1
libusb: 0.551544 info [darwin_handle_callback] handling bulk completion
with kernel status -536854449
libusb: 0.551550 warning [darwin_transfer_status] transfer error: pipe
is stalled
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 libusb-1.0.9 while on Linux I'm using the libusb package
shipped with Ubuntu. I also tried using the old libusb-0.1.12. Same
problem: Works on Linux, fails on OSX. Any help is highly appreciated.
--
Bye, K <http://www.ailis.de/~k/>
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
|