libftdi Archives

Subject: Re: [libftdi-1.0] Limit read buffer chunksize to 16384 on Linux

From: Jim Paris <jim@xxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Sun, 14 Feb 2010 04:58:00 -0500
Jie Zhang wrote:
> We can't set readbuffer_chunksize larger than MAX_BULK_BUFFER_LENGTH,
> which is defined in libusb-1.0, on Linux. Otherwise, each USB read
> request will be divided into multiple (to be exactly, 4) URBs. The
> last 3 URBs of these 4 URBs will usually result in abnormal reaps
> because we usually request small number of data. The abnormal reaps
> will concatenate empty ftdi packets to other packet on Linux kernel
> older than 2.6.32. libftdi cannot parse such combined packet. This
> will cause issue for UrJTAG when using libftdi-1.0 with libusb-1.0. I
> have committed this patch on the libftdi-1.0 git tree.
> 
> 
> Jie
> 
> 
> --
> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
> To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   
> Index: src/ftdi.c
> ===================================================================
> --- src/ftdi.c        (revision 3932)
> +++ src/ftdi.c        (working copy)
> @@ -1621,6 +1621,14 @@ int ftdi_read_data_set_chunksize(struct
>      // Invalidate all remaining data
>      ftdi->readbuffer_offset = 0;
>      ftdi->readbuffer_remaining = 0;
> +#ifdef __linux__
> +    /* We can't set readbuffer_chunksize larger than MAX_BULK_BUFFER_LENGTH,
> +       which is defined in libusb-1.0.  Otherwise, each USB read request will
> +       be divided into multiple URBs.  This will cause issues on Linux kernel
> +       older than 2.6.32.  */
> +    if (chunksize > 16384)
> +        chunksize = 16384;

Shouldn't this be

> +    if (chunksize > MAX_BULK_BUFFER_LENGTH)
> +        chunksize = MAX_BULK_BUFFER_LENGTH;

-jim

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

Current Thread