libftdi Archives

Subject: Re: variable shadowing

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 29 Sep 2014 11:04:35 +0200
>>>>> "Thomas" == Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx> writes:

    Thomas> Hi Xan, On Sunday, 14. September 2014 10:38:36 xantares 09
    Thomas> wrote:
    >> in ftdi_stream.c:155, the return code declaration at beginnign of
    >> ftdi_readstream int err = 0; is overriden by at line 243 by:
    >> 
    >> do { FTDIProgressInfo *progress = &state.progress; const double
    >> progressInterval = 1.0; struct timeval timeout = { 0,
    >> ftdi->usb_read_timeout }; struct timeval now;
    >> 
    >> int err = libusb_handle_events_timeout(ftdi->usb_ctx, &timeout); if
    >> (err == LIBUSB_ERROR_INTERRUPTED) /* restart interrupted events */
    >> err = libusb_handle_events_timeout(ftdi->usb_ctx, &timeout);
    >> 
    >> 
    >> if the final return code should depend on the return code of
    >> libusb_handle_events_timeout, it's a bug, if not a different name
    >> should be chosen.

    Thomas> thanks for reporting this issue, I've applied your patch.

    Thomas> I think you are right, we should probably change "int err =" to
    Thomas> just "err =".

    Thomas> @Uwe: Do you agree? It's your code :)

Your solution sounds sensible.

    Thomas> Also, looking closely at that code, it calls
    Thomas> libusb_handle_events_timeout() again on
    Thomas> LIBUSB_ERROR_INTERRUPTED. But it does that only *once*.  Is that
    Thomas> intentional? What if the system is temporarily really busy?

What to do in case of error, especially in errors your experiments did't
show, is always problematic. I think our default  for timeout is 5
Milliseconds. With two times that timeout and at a rate of 20 MByte per
second, after 10 ms we have 200 kbyte outstanding. Mostly the buffer on the
ftdi side will hold less. So probably I thought that one retry is a good
compromise. 

But if people have other experience, the code is not fixed in stone...

Bye
-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

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

Current Thread