serial driver open/flush question

serial driver open/flush question

Post by Grant Edwar » Sat, 07 Dec 2002 22:27:53



I've noticed that every time a serial port is opened, the
serial.c driver (among others), resets the UART (flushing
FIFOs, set baud rate, etc.).  Why is this done even when the
device is already open?

Doing so results in some odd behavior.  For example with a
loopback plug connected to /dev/ttyS1, do the following from
two terminals:

Terminal 1             Terminal 2
---------------------  --------------------------
                       (stty 2400 -echo raw -ixon -ixoff -crtscts;cat)</dev/ttyS1
ls -l >/dev/ttySI1

                       [output from ls scrolls by]

                       [press ctrl-C in middle of data and do
                       another command while data is still
                       being written to port]

                       (stty 2400 -echo raw -ixon -ixoff -crtscts;cat)</dev/ttyS1

                       [nothing displayed.  after data stops
                       and port is closed by other terminal,
                       remaining data appears all at once.]

If an a serial driver's open is called when the port is already
open and the tty struct is the same one already in use, why not
just increment use counters and return?   Wouldn't this be more
policy neutral regarding multiple opens?

--
Grant Edwards                   grante             Yow!  Ask me the DIFFERENCE
                                  at               between PHIL SILVERS and
                               visi.com            ALEXANDER HAIG!!

 
 
 

serial driver open/flush question

Post by Pete Zaitc » Sun, 08 Dec 2002 02:43:04



Quote:> I've noticed that every time a serial port is opened, the
> serial.c driver (among others), resets the UART (flushing
> FIFOs, set baud rate, etc.).  Why is this done even when the
> device is already open?

Nobody was bold enough to touch the tty layer since Ted left it alone.
It's an unimaginable mess.

-- Pete

 
 
 

1. No way to flush rx buffer in serial driver?

I've been looking at serial driver code (2.4.18), and low level
drivers provide a way to flush the tx buffer by calling

         tty->driver.flush_buffer(tty);    // from tty_ioctl.c

but there does not seem to be a corresponding call to flush the
rx buffer.  Why not?

TCOFLUSH flushes both line-discipline and low-level driver
buffers, but TCIFLUSH only flushes line-discipline buffers.
This seems wrong...

--
Grant Edwards                   grante             Yow!  Wait... is this a FUN
                                  at               THING or the END of LIFE in
                               visi.com            Petticoat Junction??

2. Error reading man page

3. Reloading FP rules + flush of state=hang of open connections

4. S3 Savage 3D ???

5. Flushing a serial device in C

6. Please help with my ownership on /var/spool!

7. help: flushing serial output from C prog.

8. help with a viper 770 and RH 6.0

9. Serial buffer flushing problems under 1.0

10. Flushing Serial Port (long)

11. flushing serial port

12. Open Desktop 5.0 driver question

13. Serial mouse only works during installation in graphics mode, problem with 'serial device driver'