Fwd: possible libusb osx error

View: New views
1 Messages — Rating Filter:   Alert me  

Fwd: possible libusb osx error

by Daniel Drake :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Nathan,

For when you have time:

1. See the mail inline below

2. On Linux, bad things could happen if libusb_cancel_transfer() was
invoked while another thread was handling the completion of that
transfer. Does darwin have potential races like that? If so, perhaps you
could make sure per-transfer data is protected using the new transfer
lock (see commit 69830057)

3. Under libusb's design, you should be able to send zero-length packets
  to bulk/intr endpoints by submitting a transfer of length 0 and a NULL
buffer. But we had a bug in the Linux part of libusb which prevented
that, and there were also some bugs in the kernel preventing this from
working. Would be nice to confirm that this is working on Darwin.

4. some protocols require an incomplete packet to be sent at the end of
every logical message. Therefore if the request is the multiple of a
packet size, a special zero-length packet must be sent after. we're
considering adding a flag to simplify things for users who work with
devices with this constraint, see
http://libusb.org/attachment/ticket/6/0001-Add-LIBUSB_TRANSFER_ZERO_PACKET-6.patch
Would also be nice to have a darwin implementation there.

thanks!
Daniel


-------- Original Message --------
Subject: possible libusb osx error
Date: Fri, 6 Nov 2009 16:36:06 +0200 (EET)
From: Tuomo Penttinen <tuomo.s.penttinen@...>
Reply-To: tuomo.s.penttinen@...
To: dan@...

Hello.

Hopefully it is okay for me to contact you directly about an issue I
encountered with libusb 1.0.3. If not, please just tell me. In any case,
here's what happened.

I'm developing software for a device with USB connectivity and I decided
to give libusb a try. I got my code working easily on Linux, but
encountered a problem with Mac OS X that seemed a bit weird. Basically,
everything else went fine until I tried communicating with a device. The
communication failed due to libusb being unable to map a provided endpoint
address with a piperef. After verifying in every which way that my code
was correct I peeked inside libusb and found out something that appears as
a small error to me.

The documentation instructs to make a call to libusb_claim_interface()
before doing any I/O and more importantly for this particular issue,
making a call to libusb_set_interface_alt_setting(). On OS X a back-end
function darwin_claim_interface() is called, which in turn sets up some
internal structures, such as the endpoints for future communication.
However, darwin_set_interface_altsetting() does not update these
structures. So, after I've done libusb_claim_interface() and
libusb_set_interface_alt_setting() the internal endpoint information
doesn't reflect the chosen altsetting, which is the reason I was getting
the mapping error between endpoint addresses and piperefs.

I made a small fix, after which everything seems to work fine. In essence,
I added a call to get_endpoints() just before returning from the
darwin_set_interface_altsetting(). However, I didn't study the code enough
to know if this is a proper fix for the issue. In any case, could you
verify this?

Thanks for your efforts!

Regards,

Tuomo


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Libusb-devel mailing list
Libusb-devel@...
https://lists.sourceforge.net/lists/listinfo/libusb-devel