libftdi Archives

Subject: Re: libftdi: Make ftdi_read_data() honor usb_read_timeout

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 6 Jul 2010 14:23:05 +0200
Hello Uwe,

On Friday, 25. June 2010 18:03:07 Uwe Bonnes wrote:
> I would expect that the ftdi_read_data() call returns when either the
> requested number of bytes has been read or when zero of fewer then the
> requested number of bytes has been read _and_ the timeout happened.

Sounds reasonable, atleast in a blocking-mode.

> However the present implementation returns immediate, without waiting the
> usb_read_timeout. This happens as
>            ret = libusb_bulk_transfer (ftdi->usb_dev, ftdi->out_ep,\
>                  ftdi->readbuffer, ftdi->readbuffer_chunksize,
>                  &actual_length, ftdi->usb_read_timeout);
> will immediate return the two status bytes and
>            else if (actual_length <= 2)
>            {
>                // no more data to read?
>                return offset;
> will always return, even when there is no data.


> Appended patch for libusb-0 now loops until the timeout has been hit or
> all bytes read or a hard error happened.

One thing comes to my mind: What happens to applications
expecting the current behavior? I'm currently trying
to figure out if this would break something. Hmm.


libftdi - see for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread