Re: reading on serial port slow...



On 2007-12-17, Bob Hauck <postmaster@xxxxxxxxxxxxxxxxxxxxx> wrote:

Another issue is the hardware FIFO in the serial port. If you
use the default port settings the hardware will only signal an
interrupt once the FIFO has reached a certain fullness or the
FIFO has some characters waiting but no new ones have arrived
for a while. IIRC "a while" is a few character times.

In the "standard" 16550 implimenation from National, it's 4
character times. Most of the PC chipsets do the same.

The "low latency" IOCTL flag that someone told you about sets
the port to signal an interrupt after each character.

No, it sets up the driver so that it transfers data to the line
discipline layer on every receive interrupt (rather than doing
it once every 10ms).

If you are sending short messages this will minimize the
waiting time caused by the FIFO at the cost of higher
interrupt overhead.

If you want to receive single characters right away, you'll
need to disable the receive FIFO as well as set the low-latency
flag. IIRC, you can disable the rx FIFO either by setting the
rx_trigger value to 1 or by forcing the UART type to 16450.

Doing this at very high baud rates will eat up some CPU time...

Nevertheless, I still wonder at the difference in behavior between

a) nanosleep - nonblocking read and..

b) select, non-blocking read.

With select() you know that there is actually data ready.
With nanosleep() you are just assuming that there is data
ready, which assumption seems to be wrong.

With select, you wake up immediately upon receipt of data. With
sleep, you wait for a fixed period of time no matter how soon
the data arrives.

If you want to do some processing if there is no data ready
for some period of time, just use select with a timeout.

Using select() is definitely the correct solution (regardless
of what the author of some broken "port abstraction" class
seems to think.)

Wouldn't it be easier to just fix the broken port class than to
spend days and days arguing with everybody who tries to help?

--
Grant Edwards grante Yow! On the road, ZIPPY
at is a pinhead without a
visi.com purpose, but never without
a POINT.
.



Relevant Pages

  • Re: reading on serial port slow...
    ... the FIFO has reached a certain fullness or the FIFO has some characters ... waiting but no new ones have arrived for a while. ... to signal an interrupt after each character. ...
    (comp.os.linux.development.system)
  • Help needed with SCI interrupts (HC12)
    ... over the SCI1 port, and then transmits them over the Ethernet port. ... Interrupt function for the SCI1 port. ... extern void SCI1_isr_handler; ... /* Number of characters in the Fifo ...
    (comp.arch.embedded)
  • Re: RS 232 Code =?ISO-8859-1?Q?f=FCr_Microcontroller_=28GCC_?= =?ISO-8859-1?Q?Compil
    ... Bei den Motorolas gibt es 16 Bit Timer bei denen man ... Interrupt den Timerinhalt zwischenspeichern. ... Alle RXD-Pins auf einen Port. ... liest Port und schreibt in FIFO im RAM. ...
    (de.sci.electronics)
  • Re: reading on serial port slow...
    ... No, I'm using nanosleep currently, and then a non-blocking read. ... Another issue is the hardware FIFO in the serial port. ... to signal an interrupt after each character. ...
    (comp.os.linux.development.system)
  • Request for comments - kgets()
    ... macro and a function-like macro macros below) ... pointers, dereferencing pointers, pointer arithmetic, and how (at ... character by character I can discuss a conceptual model of the ... FIFO Model - A block of memory having two pointers. ...
    (comp.lang.c)