libftdi Archives

Subject: Re: Bug in ftdi_read_data

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 17 Aug 2010 14:10:08 +0200
On Tuesday, 17. August 2010 11:05:41 Uwe Bonnes wrote:
>     Thomas> Thanks for reporting this. IIRC the code change is related to
>     Thomas> the recent "Let ftdi_read_data() honor usb_read_timeout"
>     Thomas> commit. The proposed fix would revert an intentional (?) part
> of Thomas> Uwe's change and I guess this could break the timeout code.
> Uwe, Thomas> can you take a look?
> I think Hermanns solution is right. When the amount of data requested has
> been read, the function should return.

Thanks. I'd like to commit this:

diff --git a/src/ftdi.c b/src/ftdi.c
index bbbeb9a..f64301d 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -1655,6 +1655,7 @@ int ftdi_read_data(struct ftdi_context *ftdi, unsigned 
char *buf, int size)
                 /* printf("Returning part: %d - size: %d - offset: %d - 
ret: %d - remaining: %d\n",
                 part_size, size, offset, ret, ftdi->readbuffer_remaining); 
+                return offset;

"offset" should be equal to "size". It's a small variation
from Hermann's proposed change:

1. "return offset" like the rest of the code and that's also
   the original state before the timeout code was added.

2. Do the "return" at the end of the block


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

Current Thread