home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.sys5.r4:978 comp.unix.sys5.r4:979
- Newsgroups: comp.unix.sys5.r4,comp.unix.sys5.r4
- Path: sparky!uunet!gatech!destroyer!mudos!mju
- From: mju@mudos.ann-arbor.mi.us (Marc Unangst)
- Subject: Re: Can Sys/V force DTR low or high?
- Message-ID: <BzqnD8.9FD@mudos.ann-arbor.mi.us>
- Date: Thu, 24 Dec 1992 00:43:54 GMT
- References: <1406@minya.UUCP>
- Organization: The Programmer's Pit Stop, Ann Arbor MI
- Keywords: DTR
- Lines: 55
-
- In article <1406@minya.UUCP> jcsu@minya.UUCP (John Chambers) writes:
- >So is it possible for a Sys/V process that has a port open to forcibly
- >drop DTR? (If not, I have yet another entry in my list of reasons that
- >we should list variants of Sys/V as unacceptable for the project. ;-)
- >Might it be documented anywhere?
-
- Try the termio(7) manpage. On my SVR4 (Esix 4.0.3), it says this:
-
- The CBAUD bits specify the baud rate. The zero baud rate,
- B0, is used to hang up the connection. If B0 is specified,
- the data-terminal-ready signal is not asserted. Normally,
- this disconnects the line.
-
- In addition, termios(2) has this to say:
-
- cfsetospeed sets the output baud rate stored in the termios
- structure pointed to by termios_p to speed. The zero baud
- rate, B0, is used to terminate the connection. If B0 is
- specified, the modem control lines are no longer be
- asserted. Normally, this disconnects the line.
-
- So, you could do something like this to disconnect the line:
-
- struct termios tty;
- int fd;
- /* ... */
- tcgetattr(fd, &tty); /* get current parameters */
- cfsetospeed(&tty, 0); /* set speed = 0 */
- tcsetattr(fd, TCSAFLUSH, &tty); /* write parameters */
-
- Or, if you're using termio instead of termios:
-
- struct termio tty;
- int fd;
- /* ... */
- ioctl(fd, TCGETA, &tty); /* get current parameters */
- tty.c_cflag &= ~CBAUD; /* turn off all speed flags */
- tty.c_cflag |= B0; /* set speed = 0 */
- ioctl(fd, TCSETAF, &tty); /* write parameters */
-
- Or, you can use the new termios modem-control ioctls:
-
- int fd;
- /* ... */
- ioctl(fd, TIOCMBIC, TIOCM_DTR); /* turn off DTR */
-
- See, there are lots of ways of doing it under SVR4 or any other
- POSIX-compliant OS. And at least one way of doing it under SVRx,
- where x <= 3.
-
- --
- Marc Unangst, N8VRH | "Of course, in order to understand this you
- mju@mudos.ann-arbor.mi.us | have to remember that the nucleus of the atom
- | is squishy."
- | -W. Scheider, from a Physics lecture
-