Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Serial Half-Duplex with RTS/CTS

525 views
Skip to first unread message

Timothy Jamison

unread,
May 9, 2003, 6:30:54 PM5/9/03
to
I wish to implement a form of Half-Duplex with the serial port.
Specifically, I need to set RTS before beginning transmission,
and only transmit while CTS is set. Then when the last byte
and stop bit are physically sent thru the serial port, I need to
turn off RTS.

Setting the flag CRTSCTS does half the job -- it won't transmit
until CTS is on, so that parts good. But it keeps RTS on all the
time, and that is bad.

Is there a half-duplex mode that will do what I want? Or is there
a way I can determine when the data is finished being sent thru the
FIFO? I am using a 16550 compatible chip.

My requirements aren't that strict. If it turns off RTS a little too soon
or too late it isn't the end of the world.

I would really hate to have to delve into the lower-level Linux code
like serial.c, but if thats the case, then I am up to the challenge :^)

Thanks,
Timothy Jamison
Of the Anything Goes School of Martial Arts Computer Programming
Our Code - Whatever compiles and works!


Floyd Davidson

unread,
May 9, 2003, 7:20:22 PM5/9/03
to

Interesting scenario. I think that about all you can do is
check CTS to determine that the transmitter should be able to
send, then wait an interval long enough to allow the data to
have been sent, look at CTS again (or maybe several times at
smaller intervals) and if it is still right, assume that the
data has been sent and drop RTS. That isn't perfect though, so
some kind of data verification with the ability to request a
re-transmission is probably in order.

--
Floyd L. Davidson <http://www.ptialaska.net/~floyd>
Ukpeagvik (Barrow, Alaska) fl...@barrow.com

Grant Edwards

unread,
May 10, 2003, 9:41:15 PM5/10/03
to
In article <b9h7q2$8pr$1...@usenet.switch.com>, Timothy Jamison wrote:

> I wish to implement a form of Half-Duplex with the serial port.
> Specifically, I need to set RTS before beginning transmission,
> and only transmit while CTS is set. Then when the last byte
> and stop bit are physically sent thru the serial port, I need to
> turn off RTS.

I spent some time a few years ago trying to impliment a half-duplex ;mode in
the 16550 driver. Due to vagueries in Mobo UARTs it never worked reliably
and I gave up. If you really need to do half-duplex, the only way I've ever
gotten to work is to buy a serial board that supports RTS/CTS half duplex
operation.

> Is there a half-duplex mode that will do what I want? Or is there
> a way I can determine when the data is finished being sent thru the
> FIFO? I am using a 16550 compatible chip.
>
> My requirements aren't that strict. If it turns off RTS a little too soon
> or too late it isn't the end of the world.

How about a 4000-series CMOS one-shot that's set to time out in one byte
time, and triggered by the Tx Data line?

> I would really hate to have to delve into the lower-level Linux code
> like serial.c, but if thats the case, then I am up to the challenge :^)

Good luck. I couldn't get it to work, and I've been doing UART stuff for 20
years, adn Unix device drivers for 10 years.

--
Grant Edwards grante Yow! I'm having
at a tax-deductible
visi.com experience! I need an
energy crunch!!

Message has been deleted

Grant Edwards

unread,
May 11, 2003, 8:35:25 PM5/11/03
to
In article <jbjtbv83l2t3mnbar...@4ax.com>, Alex Pavloff wrote:

> Conclusion: _Good_ drop-the-RTS-line-when-done-sending control is
> impossible to pull off with hardware. Processor-intensive RTS control can
> be done with TIOCSERGETLSR.

Agreed. Sometimes you can disable the tx fifo and play the "extra transmit
bytes" game where you add two extra transmit bytes, and shut of RTS when you
get the tx interrupt after you've written the second "extra" byte. I've
gotten that to work with some 16550s but not others. The timing of the tx
interrupt doesn't seem to be very consistent.

IMO, the best options are:

1) Build a hardware dongle with a 4000-series one-shot triggered by tx data
(powered from serial port lines with gnd at -5 and supply at +5). The
period of the one-shot needs to be set according to the baud rate. This
scheme has worked for me with Linux and Solaris, but it depends on being
able to loose an initial bit (or byte). If you're modem has a slow
turn-around time, you'll have problems, since RTS isn't asserted until
after tx data starts.

2) Buy a serial board that supports half-duplex (e.g. something with a
16850 or similar UART). Last time I checked (several years back)
Cyclades had boards that worked nicely, but there was some doubt if
half-duplex would be supported in future versions.

--
Grant Edwards grante Yow! Is this BOISE??
at
visi.com

Timothy Jamison

unread,
May 15, 2003, 12:50:50 PM5/15/03
to
Hi all,

I got it to work fairly well just in the application code.

All I did was configure it for CRTSCTS mode, then just
before I transmit data I turn on RTS, and write out my
message. And then I do a tcdrain(). After that I clear
RTS.

I don't have a clue where tcdrain is implemented, but it
works, not perfectly, but good enough. Most of the time
RTS stays on for a character length or 2 after its all
transmitted, but not much more... only once did I see it
turn RTS off before the last character was transmitted.

Thanks for all your help
-Tim Jamison

0 new messages