libftdi Archives

Subject: Re: ftdi_transfer_data_done() timeout

From: Janne Heikkinen <janne.m.heikkinen@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 15 Jan 2014 11:40:24 +0200
I tried using libusb_handle_events_timeout() but had no luck with it and
then I tried to add simple timeout like this:

int ftdi_transfer_data_done(struct ftdi_transfer_control *tc)
{
    int ret;

    uint32_t t0 = msec_time();

    while (!tc->completed)
    {
        ret = libusb_handle_events(tc->ftdi->usb_ctx);

        if (time_diff(msec_time(), t0) > (int32_t)1000)
            ret = LIBUSB_ERROR_TIMEOUT;

        if (ret < 0)
        {
            if (ret == LIBUSB_ERROR_INTERRUPTED)
                continue;
            libusb_cancel_transfer(tc->transfer);
            while (!tc->completed)
                if (libusb_handle_events(tc->ftdi->usb_ctx) < 0)
                    break;
            libusb_free_transfer(tc->transfer);
            free (tc);
            return ret;
        }
    }


But now this hangs in the inner while(!tc->completed) loop.

On Tue, Jan 14, 2014 at 10:20 PM, Janne Heikkinen
<janne.m.heikkinen@xxxxxxxxx> wrote:
> Hi,
>
> I've been using code like to to read from FT2232H is sync FIFO245 mode:
>
> struct ftdi_transfer_control *c = ftdi_read_data_submit(ftdi,
> lpBuffer, dwBytesToRead);
>
> int ret = ftdi_transfer_data_done(c);
>
> I was expecting ftdi_transfer_data_done() to timeout after the default timeout
> which seems to be 5 seconds if there is no data to read but it seems to hang
> instead?
>
> - Janne

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

Current Thread