[comp.unix.aix] RTS/CTS flow control

kevin@msa3b.UUCP (Kevin P. Kleinfelter) (08/14/90)

How does one enable/disable RTS/CTS flow control on a tty line using
AIX V3, from a C program?  The only info provided by "info" is that
"stty add rts" can be issued from the shell level.

I have issued "stty add rts" from the shell, then entered a C program that
puts the terminal in raw mode, and it appears that RTS/CTS flow control
is not enabled.  That is to say, a line monitor shows that data is
received, RTS is not dropped, yet the last few bytes of the data are
not returned by a "read" in my code.

"info" has references to RTS within ioctl, but it only tells how to examine
the bit, not how to tell the driver to manage RTS/CTS flow control.

HELP.
-- 
Kevin Kleinfelter @ Dun and Bradstreet Software, Inc (404) 239-2347
{emory,gatech}!nanovx!msa3b!kevin

"Don't hold your finger on the button if the motor ain't goin' roundy-roundy."

jeffe@sandino.austin.ibm.com (Peter Jeffe 512.823.4091) (08/17/90)

In article <1352@msa3b.UUCP> kevin@msa3b.UUCP (Kevin P. Kleinfelter) writes:
>How does one enable/disable RTS/CTS flow control on a tty line using
>AIX V3, from a C program?  The only info provided by "info" is that
>"stty add rts" can be issued from the shell level.

This is esentially what an "stty add rts" does:

#include <sys/ioctl.h>
main()
{
    if (ioctl(0, TXADDCD, "rts"))
	perror("ioctl");
}

Substitute TXDELCD if you want to "stty del rts".
-------------------------------------------------------------------------------
Peter Jeffe   ...uunet!cs.utexas.edu!ibmaus!auschs!sandino.austin.ibm.com!jeffe
        first they want a disclaimer, then they make you pee in a jar,
                   then they come for you in the night

RAH@IBM.COM ("Russell A. Heise") (10/10/90)

 kevin@msa3b.UUCP (Kevin P. Kleinfelter) writes:

 > How does one enable/disable RTS/CTS flow control on a tty line using
 > AIX V3, from a C program?  The only info provided by "info" is that
 > "stty add rts" can be issued from the shell level.
 >
 > I have issued "stty add rts" from the shell, then entered a C program that
 > puts the terminal in raw mode, and it appears that RTS/CTS flow control
 > is not enabled.  That is to say, a line monitor shows that data is
 > received, RTS is not dropped, yet the last few bytes of the data are
 > not returned by a "read" in my code.

 An associate offers the following sample program:
 --- cut here
 #include <termios.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/errno.h>
 #include <fnctl.h>
 #define MODEM_LINE "/dev/tty1"
 main()
 LB            <== LB is left brace, RB is right brace
     int linefd;
     linefd = open (MODEM_LINE, O_RDWR);
     if (linefd == -1)
         printf ("Can't open line - errno %d\n", errno);
     else
         while (1) LB
             printf ("Drop RTS now\n");
             ioctl (linefd, TIOCMBIC, TIOCM_RTS);
             sleep (2);
             printf ("Raise RTS now\n");
             ioctl (linefd, TIOCMBIS, TIOCM_RTS);
             sleep (2);
         RB
 RB           <== supposed to be a right brace
 --- end cut here

 Of course, this code is offered without warranty.  Hope it helps.

Russ Heise, AIX Technical Support, IBM