[Bug 155752] [uart] tcdrain(3) does not work with uart(4) driver

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed Mar 4 12:47:44 UTC 2015


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=155752

nkoch at demig.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nkoch at demig.de

--- Comment #1 from nkoch at demig.de ---
I came across the same problem: I need to switch the transmitter
of an external RS232/RS485 converter on before satarting transmittision
and off afterwards using RTS.

My quick driver hack is to always call the chip-specific drain
function whenever there is a request to turn off RTS.

This is my patch to the 16550 code:

--- uart_dev_ns8250.c.orig    2015-03-04 13:37:04.000000000 +0100
+++ uart_dev_ns8250.c    2015-03-04 13:40:05.000000000 +0100
@@ -886,6 +886,10 @@
         }
     } while (!atomic_cmpset_32(&sc->sc_hwsig, old, new));
     uart_lock(sc->sc_hwmtx);
+#ifdef UART_HACK_DRAIN_RTSOFF
+        if ((sig & SER_DRTS) && !(sig & SER_RTS))
+                ns8250_drain(bas, UART_DRAIN_TRANSMITTER);
+#endif
     ns8250->mcr &= ~(MCR_DTR|MCR_RTS);
     if (new & SER_DTR)
         ns8250->mcr |= MCR_DTR;

The patch is against head but has been tested with 9.1
using a scope with protocol analyzer function.

I did not look into the other chips' code so may it
will not universally work.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list