libftdi Archives

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

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: Thomas Heller <theller@xxxxxxxxxx>
Date: Tue, 29 May 2012 15:46:35 +0200
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 :)

ftdi_read_data() was implemented to act like the posix read() function.
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"?

Thomas

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

Current Thread