libftdi Archives

Subject: Re: Asynchronous Read Hangs

From: Jim Hendry <hendryjh@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Thu, 28 Feb 2013 18:28:18 -0500
OS: ubuntu 12.04 and 12.10

Switching to libusbx made no difference.

Things work well if I queue of a bunch of transmits with ftdi_write_data_submit and then use regular synchronous ftdi_read_data to read back the data. Unfortunately, when I move the app to a slower processor the bit error rate shoots way up. My assumption is that receive buffers in libusbx/libftdi are overflowing, although I am not sure how to check this. I anticipate that queuing up reads with ftdi_read_data_submits will alleviate the problem by providing my receive buffers to the underlying code. My data rates are 40Mb/s in each directions (80Mb/s total).

I turned on logging in libusbx and noticed something interesting. When I sent two 512 bytes packets of data, each followed by a 512 byte read, the allocated urbs looked like:
[ 0.002312] [00006ba6] libusbx: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 512
[ 0.002325] [00006ba6] libusbx: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 4096
[ 0.002396] [00006ba6] libusbx: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 512
[ 0.002407] [00006ba6] libusbx: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 4096

So it looks like the urbs for reads are always 4096 bytes (or minimum). In this case I could see the [reap_for_handle] msgs showing two 512 bytes writes, and then sometime later a 1030 bytes xfer for the read. So libusx has read back the data. But ftdi_transfer_data_done hangs waiting for the first 512 bytes.

When I switch my packet size to 4096, then I am able to read a few packets (the exact number changes every run) before ftdi_transfer_data_done hangs waiting for a read.

If I do a run where there is only ever one outstanding ftdi_read_data_submit then everything is fine. Is there a libftdi limitation to only have one outstanding async read request? The only app that I found that uses ftdi_read_data_submit is urjtag, but it only sends one and then waits for it.

Thanks,
Jim


On Wed, Feb 27, 2013 at 6:22 PM, Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
On Wed, Feb 27, 2013 at 6:16 AM, Jim Hendry <hendryjh@xxxxxxxxx> wrote:
> Using libftdi1-1.0.tar.bz2 and the latest stable libusb-1.0.9.

Under which OS? You may want to try libusbx.git
instead of libusb-1.0.9 release which is not usable
under Windows and has some bugs under Linux
and Mac OS X.

libusbx: http://libusbx.org/
libusbx.git: https://github.com/libusbx/libusbx


--
Xiaofan

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




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


Current Thread