Parent document is top of "comp.unix.aix Frequently Asked Questions (Part 5 of 5)"
Previous document is "8.07: How to configure dialup SLIP"
Next document is "8.09: How can I hack libc.a to alter how hostnames are resolved?"

8.08: Disabling software flow control; using RTS/CTS.

[ formerly in section 1.613 ]

/* This program is an adaptation of a program provided by IBM Defect Support.
   It is provided without warrantee, or support.

   The syntax of the command is:

	setrts tty [tty [tty [...]]]

   The program will loop through each tty provided on the command line, and 
   turn on the 'rts' line discipline.  The program does not require that
   the Carrier Detect signal be held high to keep the serial device from 
   blocking on the attempt to open it.  The program works for all valid ttys.

   BUGS: None that are known; however, using the program to set 'ptys' may
   cause the 'pty' to become unusable.

   This program was written by Robin D. Wilson, Pencom Software (with the
   specific 'ioctl()' call provided by the IBM Defect Support Center.

   I call it: "setrts"
   
   To compile:
   cc -O -o setrts setrts.c
   strip setrts
   
   (Funny, but if you strip with the compiler (i.e., cc -s), you end up with
   120 extra bytes in the executable...)
*/

#include <stdio.h>
#include <fcntl.h>
#include <termios.h>
#include <sys/tty.h>
#include <string.h>
#include <sys/param.h>
#include <unistd.h>

#define DEVDIR		"/dev/"
#define	LINEDISP	"rts"

main (argc, argv)
int argc;
char **argv;
{
	int tty;
	char ttyname[MAXPATHLEN];

/*	Give a 'usage' recommendation if they don't provide an argument */
	if (argc < 2) {
	   fprintf(stderr, "usage: %s <ttyn> [ttyn [ttyn [...]]]\n",argv[0]);
	   exit(-1);
	}
 /*	Otherwise, loop through all the arguments... */
	else while (--argc >= 1) {
		argv++;
 /*	Check to see if they input the 'tty' names with the DEVDIR on them...
 *	If not, put it on...
 */
		if (strncmp(DEVDIR, argv[0], strlen(DEVDIR)) != 0) {
			strcpy(ttyname, DEVDIR);
			strcat(ttyname, argv[0]);
		}
		else
			strcpy(ttyname, argv[0]);

/*	Open the tty.  Use the non-blocking open (O_NDELAY) to open without a 
 *	carrier (CD) present on the line...
 */
		if ((tty = open(ttyname, O_RDWR|O_NDELAY)) < 0) {
		   fprintf(stderr, "%s: couldn't open tty device.\n",ttyname);
		   exit (-2);
		}
 /*	Add the 'rts' line discipline... */
		(void)ioctl(tty, TXADDCD, LINEDISP);
		(void)close(tty);
	}
}

Parent document is top of "comp.unix.aix Frequently Asked Questions (Part 5 of 5)"
Previous document is "8.07: How to configure dialup SLIP"
Next document is "8.09: How can I hack libc.a to alter how hostnames are resolved?"