[prev in list] [next in list] [prev in thread] [next in thread]
List: libftdi
Subject: Re: ftdi_transfer_data_done() timeout
From: Janne Heikkinen <janne.m.heikkinen () gmail ! com>
Date: 2014-01-15 17:13:02
Message-ID: CAMEJZcG=F177j5iTpVKy+mnt3SzWudqZDePBdNumJ8fJ1eruVg () mail ! gmail ! com
[Download RAW message or body]
Ok, I haven't used libusb directly before but to me it seems that the
libFTDI's callback function needs to be modified to support this..
15.1.2014 11.40 kirjoitti "Janne Heikkinen" <janne.m.heikkinen@gmail.com>:
> 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@gmail.com> 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@developer.intra2net.com
[Attachment #3 (text/html)]
<p dir="ltr">Ok, I haven't used libusb directly before but to me it seems that \
the libFTDI's callback function needs to be modified to support this..</p> <div \
class="gmail_quote">15.1.2014 11.40 kirjoitti "Janne Heikkinen" <<a \
href="mailto:janne.m.heikkinen@gmail.com">janne.m.heikkinen@gmail.com</a>>:<br \
type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"> I tried using \
libusb_handle_events_timeout() but had no luck with it and<br> then I tried to add \
simple timeout like this:<br> <br>
int ftdi_transfer_data_done(struct ftdi_transfer_control *tc)<br>
{<br>
int ret;<br>
<br>
uint32_t t0 = msec_time();<br>
<br>
while (!tc->completed)<br>
{<br>
ret = libusb_handle_events(tc->ftdi->usb_ctx);<br>
<br>
if (time_diff(msec_time(), t0) > (int32_t)1000)<br>
ret = LIBUSB_ERROR_TIMEOUT;<br>
<br>
if (ret < 0)<br>
{<br>
if (ret == LIBUSB_ERROR_INTERRUPTED)<br>
continue;<br>
libusb_cancel_transfer(tc->transfer);<br>
while (!tc->completed)<br>
if (libusb_handle_events(tc->ftdi->usb_ctx) < 0)<br>
break;<br>
libusb_free_transfer(tc->transfer);<br>
free (tc);<br>
return ret;<br>
}<br>
}<br>
<br>
<br>
But now this hangs in the inner while(!tc->completed) loop.<br>
<br>
On Tue, Jan 14, 2014 at 10:20 PM, Janne Heikkinen<br>
<<a href="mailto:janne.m.heikkinen@gmail.com">janne.m.heikkinen@gmail.com</a>> \
wrote:<br> > Hi,<br>
><br>
> I've been using code like to to read from FT2232H is sync FIFO245 mode:<br>
><br>
> struct ftdi_transfer_control *c = ftdi_read_data_submit(ftdi,<br>
> lpBuffer, dwBytesToRead);<br>
><br>
> int ret = ftdi_transfer_data_done(c);<br>
><br>
> I was expecting ftdi_transfer_data_done() to timeout after the default \
timeout<br> > which seems to be 5 seconds if there is no data to read but it seems \
to hang<br> > instead?<br>
><br>
> - Janne<br>
</blockquote></div>
<br><hr><p><b>libftdi</b> - see <a \
href="http://www.intra2net.com/en/developer/libftdi">http://www.intra2net.com/en/developer/libftdi</a> \
for details.<br> To unsubscribe send a mail to <a \
href="mailto:libftdi+unsubscribe@developer.intra2net.com">libftdi+unsubscribe@developer.intra2net.com</a></p>
<br>=
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic