Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.unix.aix Frequently Asked Questions (Part 5 of 5)
Section - 8.08: Disabling software flow control; using RTS/CTS.

( Part1 - Part2 - Part3 - Part4 - Part5 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Business Photos and Profiles ]


Top Document: comp.unix.aix Frequently Asked Questions (Part 5 of 5)
Previous Document: 8.07: How to configure dialup SLIP
Next Document: 8.09: How can I hack libc.a to alter how hostnames are resolved?
See reader questions & answers on this topic! - Help others by sharing your knowledge
[ 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);
	}
}

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




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

Part1 - Part2 - Part3 - Part4 - Part5 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
bofh@mail.teleweb.pt (Jose Pina Coelho)





Last Update March 27 2014 @ 02:11 PM