linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [SOLVED] Serial buffer corruption [was Re: FTDI usb-serial possible bug]
@ 2007-05-04  8:38 Antonino Ingargiola
  2007-05-04  8:49 ` Oliver Neukum
  0 siblings, 1 reply; 59+ messages in thread
From: Antonino Ingargiola @ 2007-05-04  8:38 UTC (permalink / raw)
  To: linux-usb-users; +Cc: linux-kernel

Hi,

On 4/14/07, Antonino Ingargiola <tritemio@gmail.com> wrote:
> Hi to the list,
>
> I report a problem found with a device that use the FTDI chip to
> communicate data to pc.
>
<summary of snipped problem description>
The scenario is: a serial device streams data continuously toward the
pc. The application requires the data be read once in a while (so not
all data is read). There is a corruption reading the data (old data
mixed with the new one).

The problem is absent in windows (using the same HW device and python code).
<end summary>

I report for reference how I solved the problem.

The problem arises because (while not reading)  the input stream fills
the input buffer. Once filled, the buffer does not accept new data, so
the lost data is the new one not the old.

When one need to read the data he flushes the input buffer, but this
is not sufficient. In fact there is a second (hardware?) buffer in the
chain that, suddenly after the flush, pushes a chunk of old data in to
the input buffer. After this the new data is queued. This result in
data corruption at the edge between the new and the old data in the
buffer.

The problem has been reproduced also with an usb-serial device using
the cdc-acm driver and with two serial port linked by a null-modem
cable (so its not FTDI specific).

To solve the problem we must do a complete flush of all the buffer
chain. I do this flushing the input multiple times with a small pause
between them. In my case 10 flushes separated by a 10ms pause always
empties the whole buffer chain, so I get no corruption anymore. I'ts
not an elegant solution but it works (10 flushes are an overkill but I
want to be _really_ sure to read the correct data).

If someone know a better way to solve the problem is more than welcome
to suggest. Furthermore just a confirmation of my analysis of the
serial buffer behavior would be appreciated.

What puzzled me at first was that on windows the "flush" flushes all
the buffers, so the problem does not arises. Maybe Linux serial stack
works this way because is dictated by the POSIX standard ... I don't
know, just guessing.

Thanks,

  ~ Antonio

PS: For reference, the original report was:
http://marc.info/?l=linux-kernel&m=117683012421931&w=2

^ permalink raw reply	[flat|nested] 59+ messages in thread

end of thread, other threads:[~2007-05-09 12:01 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-04  8:38 [SOLVED] Serial buffer corruption [was Re: FTDI usb-serial possible bug] Antonino Ingargiola
2007-05-04  8:49 ` Oliver Neukum
     [not found]   ` <5486cca80705040229g53933671m658bd028cadca155@mail.gmail.com>
2007-05-04  9:33     ` Antonino Ingargiola
2007-05-04 13:41       ` Oliver Neukum
2007-05-04 14:45       ` Paul Fulghum
2007-05-04 14:56         ` Paul Fulghum
2007-05-04 14:49           ` Paul Fulghum
2007-05-04 16:04             ` Antonino Ingargiola
2007-05-04 16:56               ` Antonino Ingargiola
2007-05-04 18:02                 ` Paul Fulghum
2007-05-04 17:13                   ` Antonino Ingargiola
2007-05-04 17:20                     ` Paul Fulghum
2007-05-04 17:25                       ` Antonino Ingargiola
2007-05-04 17:41                         ` Paul Fulghum
2007-05-04 18:46                           ` Antonino Ingargiola
2007-05-04 19:06                             ` Antonino Ingargiola
2007-05-04 19:49                               ` Paul Fulghum
2007-05-04 21:21                                 ` Antonino Ingargiola
2007-05-04 10:57                                   ` Paul Fulghum
2007-05-05  9:53                                     ` Antonino Ingargiola
2007-05-05  9:56                                       ` Antonino Ingargiola
2007-05-05 10:19                                       ` Antonino Ingargiola
2007-05-04 23:30                                   ` Paul Fulghum
2007-05-05  8:26                                     ` Paul Fulghum
2007-05-05 15:11                                       ` Antonino Ingargiola
2007-05-05 16:43                                         ` Paul Fulghum
2007-05-05 16:08                                           ` Paul Fulghum
2007-05-05 16:15                                             ` Paul Fulghum
2007-05-05 16:26                                               ` Antonino Ingargiola
2007-05-05 16:58                                                 ` Antonino Ingargiola
2007-05-05 17:04                                                   ` Paul Fulghum
2007-05-05 18:08                                                     ` Antonino Ingargiola
2007-05-05 18:35                                                       ` Oliver Neukum
2007-05-06  7:06                                                         ` Antonino Ingargiola
2007-05-09  9:53                                                           ` Antonino Ingargiola
2007-05-09 10:42                                                         ` Gene Heskett
2007-05-09 11:02                                                         ` Gene Heskett
2007-05-09 12:00                                                         ` Gene Heskett
2007-05-05 16:36                                             ` Alan Cox
2007-05-05 16:54                                               ` Oliver Neukum
2007-05-05 21:49                                                 ` Alan Cox
2007-05-05 18:07                                               ` Oliver Neukum
2007-05-05 21:52                                                 ` Alan Cox
2007-05-06  7:29                                                   ` Antonino Ingargiola
2007-05-06 12:28                                                     ` Alan Cox
2007-05-06 16:39                                                       ` Antonino Ingargiola
2007-05-06 16:46                                                         ` Alan Cox
2007-05-06 21:51                                                       ` [Linux-usb-users] " Alan Stern
2007-05-07  8:07                                                         ` Antonino Ingargiola
2007-05-06 14:35                                                     ` Paul Fulghum
2007-05-07  9:11                                                       ` [Linux-usb-users] " Diego Zuccato
2007-05-07 16:34                                                         ` Alan Stern
2007-05-07 16:51                                                           ` Oliver Neukum
2007-05-07 18:25                                                             ` Alan Stern
2007-05-07 17:58                                                           ` Stephen Beaver
2007-05-06 14:49                                                   ` Paul Fulghum
2007-05-05 16:46                                             ` Oliver Neukum
2007-05-05 16:56                                               ` Paul Fulghum
2007-05-05 17:09                                                 ` Antonino Ingargiola

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).