Re: Serial port buffering?




Grant Edwards wrote:
On 2006-10-28, Charles Sullivan <cwsulliv@xxxxxxxxxxxx> wrote:

Do the standard RS232 serial port drivers in Linux/Unix
provide any buffering of received characters other than
whatever hardware buffers are in the UART?

Yes. The last time I looked, they provde 1 page buffers for
both rx and tx (on an IA32 machine, that's 4KB).

I'm wondering how to handle the situation where a burst
of perhaps several hundred characters arrives at the
serial port (with no flow control) and a process can't
wait for them all to arrive before starting what may be
a relatively time-consuming analysis. (Assuming that
the analysis can be completed before another burst
arrives.)

It should be fine unless you let more than 4K of unread bytes
get queued up -- then data gets dropped.

The flip buffer is only 512 bytes, the N_TTY buffer is 4K, so I think
its better to rely on flip buffer which is 512 byte.

--
Grant Edwards grante Yow! Is this an out-take
at from the "BRADY BUNCH"?
visi.com

.



Relevant Pages

  • Re: Serial port buffering?
    ... The copy from flip buffer to discipline buffer is through tasklet, ... of perhaps several hundred characters arrives at the ... a relatively time-consuming analysis. ...
    (comp.os.linux.development.apps)
  • serial: flushing device buffer - am I close?
    ... buffer is empty" - certainly a better approach. ... But now that I am reading the buffer until empty, ... loop will wait until data arrives, but the readalways returns zero, so ... is left unspecified whether the file position changes. ...
    (comp.unix.programmer)
  • [RFC][PATCH] TTY flip buffer SMP changes
    ... In looking at the TTY flip buffer code, ... Changes to TTY Flip Buffer ... The driver stores data to the buffer identified ... to run the flush routine in process context. ...
    (Linux-Kernel)
  • Re: serial: flushing device buffer - am I close?
    ... > two bytes in the device's buffer are residual from the last run of the ... > loop will wait until data arrives, but the readalways returns zero, so ... > is left unspecified whether the file position changes. ...
    (comp.unix.programmer)
  • Re: serial: flushing device buffer - am I close?
    ... > two bytes in the device's buffer are residual from the last run of the ... > My loop will wait until data arrives, but the readalways returns zero, ... > case it is left unspecified whether the file position changes. ...
    (comp.unix.programmer)