ioctl (ULTRIX) ioctl (ULTRIX)
NAME
tcgetattr, tcsetattr - Get and set the parameters associated with the
terminal
DIFFERENCES
The manner for establishing and controlling modem connections is dif‐
ferent for Digital UNIX and ULTRIX systems. The Digital UNIX system
uses POSIX conventions for modem control. Information about a serial
line can be inspected and altered in the POSIX termios structure, using
the tcgetattr() and tcsetattr() library functions. On ULTRIX systems,
modem control was accomplished using the TIOCCAR, IOCNAR, and TIOCWON‐
LINE requests to the ioctl() system call. These requests are not sup‐
ported on a Digital UNIX system. When porting source code, open a
serial line in the following manner:
fd = open(ttyname, O_RDWR | O_NONBLOCK);
The O_NONBLOCK flag enables you to complete a read request, in case the
CLOCAL flag is not set and you are monitoring the modem status lines.
Get the current line attributes; set the CLOCAL flag, in case it is not
already set; and turn off the O_NONBLOCK flag in the following manner:
tcgetattr(fd, &tty_termios); /* get current line attributes
*/
if ((tty_termios.c_cflag & CLOCAL) == 0) {
tty_termios.c_cflag |= CLOCAL;
tcsetattr(fd, TCSANOW, &tty_termios);
flags = fcntl(fd, F_GETFL)
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK)
You can now use your implementation-defined process for dialing the
phone number and negotiating with the modem. After this, monitor the
modem signals by doing the following:
tty_termios.c_cflag &= ~CLOCAL;
tcsetattr(fd, &tty_termios); /* watch for modem signals now
*/
alarm(40); /* set a timer; do not wait forever */
read(fd, buffer, count);/* this read() blocks, pending the
appearance of modem signals */
alarm(0); /* turn off timer */
See Appendix D for a comparison of an ULTRIX application using modem
control and a Digital UNIX application using modem control. The compar‐
ison is for an outgoing call. In addition, the appendix also
contains a sample application for an incoming call.
RELATED INFORMATION
Digital UNIX Functions:
tcgetattr(3), tcsetattr(3) delim off
ioctl (ULTRIX)