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
#include
#include
#include
#include
#include
#include

#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 [...]]]\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);
}
}



UNIXguide.net
English to Visayan Cebuano Dictionary

Find: Display: hits per page

Suggest a Site
Visayan Cebuano to English Dictionary