libftdi Archives

Subject: Re: Use libusb 1.0

From: Jie Zhang <jie.zhang@xxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 14 Aug 2009 12:28:34 +0800
Thomas Jarosch wrote:
Hello Jie,

On Tuesday, 11. August 2009 12:02:41 Jie Zhang wrote:
Would it be possible to move the libusb interface into an abstraction
layer? Most libftdi functions are using usb_control_msg(),
so only a few functions need "specialization".
Not yet. The API changes a lot between libusb 0.1 and 1.0. I attached
the patch I currently have.

The asynchronous API is changed completely with this patch. It fits
better for our needs in UrJTAG, but I don't know intra2net will like it
or not. Only async read is tested here. An example of async read looks
like

Wow, that patch is quite big. Thanks. Looking at the changes in the
public interface (ftdi.h), it should be possible to add a small indirection layer so we can switch the backends. If we have to, we can break the async mode for libusb 0.1 as it works on linux only anyway.

I'm currently thinking about adding a typedef like "ftdi_usb_device",
which either points to "usb_device" or "libusb_device" in ftdi.h.

We would need a function table to dispatch calls to usb_control_msg(),
ftdi_write_data_impl(), ftdi_read_data_impl() and so on.
This should really be 100% internal so we can change
the interface easily. What do you think?

I think this is good if we want to support both libusbs.

   struct ftdi_transfer_control *tc;
   tc = ftdi_read_data_submit(...);
   ...
   recvd = ftdi_transfer_data_done (tc);

Nice. Speaking of that, I don't see the new interfaces
in ftdi.h. Am I missing something?

Thanks! Seem I forgot to declare them in ftdi.h. You can find their definitions in ftdi.c. I'll fix this in the next patch submit.

The configure script part is copied from SANE. It needs more tweaks
after we decide how to deal with libusb 0.1.

Yes, there's still one SANE reference in there ;-)

I'll fix this in the next patch submit, too.


Jie

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
Current Thread