libftdi Archives

Subject: Re: How to use async mode

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 3 Feb 2010 18:57:18 +0100
>>>>> "Jie" == Jie Zhang <jie.zhang@xxxxxxxxxx> writes:

    Jie> Hi Uwe, On 02/04/2010 12:48 AM, Uwe Bonnes wrote:
    >> Hello,
    >> 
    >> with my FT2232H test setup, libftdi-1/libusb-1 with asyn mode enabled
    >> and following code snipplet (after setting up everything):
    >> 
    >> struct ftdi_transfer_control *tc; int size = (1<<(CHUNKEXP));
    >> unsigned char buf[size]; int actual_length; int res; if(do_async) {
    >> tc = ftdi_read_data_submit(&ftdic, buf, size); res =
    >> ftdi_transfer_data_done (tc); } else { res = ftdi_read_data(&ftdic,
    >> buf, size); } if (res>0) /*do something with the data */
    >> 
    >> I don't see any consistant difference between both modes. Reading
    >> tops out at 22 MByte/sec if no further processing is done. Writing
    >> out the data gets me down to 18 MByte/sec
    >> 
    >> Probably I use the async mode in some wrong way. Any usage hints
    >> welcome!
    >> 
    Jie> ftdi_read_data = ftdi_read_data_submit + ftdi_transfer_data_done.

    Jie> So actually the same code is executed whether do_async is true or
    Jie> not.  Generally async mode is used to submit data transfer requests
    Jie> without need to wait for their completion until you really need the
    Jie> data read back.

    Jie> I did those work about half a year ago and then switched to other
    Jie> tasks.  So I need to refresh my memory before answer your
    Jie> question. I will also try to review and test your patches for
    Jie> libftdi-1 in this week I hope.

Probably we have different needs, a non-blocking read versus a streaming
read. A streaming read would imply that we can have outstanding
ftdi_read_data_submit() calls. But in the present implementation, as soon as
the remaining buffer can not fill up the size of the request, another
libusb_fill_bulk_transfer() is started with the same readbuffer as argument,
and now both pending libusb_fill_bulk_transfer()s write to the same buffer.

Is the urjtag problem of non-blocking transactions also solved with a
streaming approach as in fastftdi?.

But then there is the other problem with compiling libusb-1 code for
windows. Or is the libusb-1 for windows effort already in some usefull
state? There was a lot mailing list activity recently...

Bye
-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

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

Current Thread