libftdi Archives

Subject: Re: [Patch][RFC]read with timeout

From: Thomas Heller <theller@xxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 29 May 2012 16:37:52 +0200
Am 29.05.2012 15:46, schrieb Thomas Jarosch:
Hi Thomas,

On Monday, 21. May 2012 20:27:01 Thomas Heller wrote:
The behaviour of the ftdi_read_data function is not so well defined
(IMO, no offense intended).  It loops calling usb_bulk_read(), collects
all the data, until the requested number of bytes have been transfered;
but it also returns when the usb_bulk_read() call didn't return any
data.

For my application, I would prefer the behaviour of the original FTDI
d2xx dll: the read() call returns when either the requested number of
bytes have been transferred or when the read-timeout has expired.

Here is a patch which implements a ftdi_read_data_timeout() function
that also has this behaviour.  The patch only works on Windows since
it GetTickCount() api call.

Is it worth to consider this extension for the official repository?

Well, if we ever want something like this, it should be cross platform :)

Would ftime(3) be cross platform enough?  Or should we use
gettimeofday(2) on non-windows?

ftdi_read_data() was implemented to act like the posix read() function.

Ok.  I would prefer supplying the timeout value in the actual
read_timeout() call (however it is named), but the alternative of
course would be to have the timeout value set as a state in the
ftdi_context structure.

Your new code still needs to wait for the libusb_bulk_transfer to time out.
What value did you configure for the "usb_read_timeout"?

I used the default of 5 seconds.  But, IIRC, I have never seen this
long timeout happening.

Thanks,
Thomas

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