libftdi Archives

Subject: RE: Question about ftdi_read_data().

From: "Michael Plante" <michael.plante@xxxxxxxxx>
To: <libftdi@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Jan 2010 00:12:34 -0600
Sivaram Gowkanapalli wrote:
>> Check out the "latency timer" functionality.
>>
>> I am not sure if your device has it.
>>
>> The datasheet of the FT4232H, says the below:
>>
>> "Latency Timer. This is really a feature of the driver and is used
>> to as a timeout to flush short packets of data back to the PC. The
>> default is 16ms, but it can be altered between 0ms and 256ms. At 0ms
>> latency you get a packet transfer on every high speed microframe."

Right.  Timing is also a function of how many bytes the device on the other
end sends back, particularly in some modes (some funny business around 62,
though I imagine that # is different for hi-speed).  If you know your device
will send something, and you have control over the hardware, some modes
allow you to toggle a pin and have it flush the data back immediately.
Another thing is that the bulk_read call has a timeout set by
ftdi_context::usb_read_timeout.  I usually set it to 100 (ms) on my FT2232D
with good results, and could probably go lower.  I don't ever set the
latency timer under about 3ms, as that gives bad results.  Sorry to be so
vague, but it's been about a year since I tweaked these.  There are two app
notes that might be of interest to you:

AN232B-03_D2XXDataThroughput.pdf
AN232B-04_DataLatencyFlow.pdf

But if I'm interpreting your question correctly, and you want it to return
quickly if there's no data there, you really do need something asynchronous,
as Jie suggested.  I've not fooled with this because my device always
responds when I poll it, but if you use async, don't use the libusb compat
layer.

Michael


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

Current Thread