home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / sys5 / r4 / 978 < prev    next >
Encoding:
Internet Message Format  |  1992-12-23  |  2.4 KB

  1. Xref: sparky comp.unix.sys5.r4:978 comp.unix.sys5.r4:979
  2. Newsgroups: comp.unix.sys5.r4,comp.unix.sys5.r4
  3. Path: sparky!uunet!gatech!destroyer!mudos!mju
  4. From: mju@mudos.ann-arbor.mi.us (Marc Unangst)
  5. Subject: Re: Can Sys/V force DTR low or high?
  6. Message-ID: <BzqnD8.9FD@mudos.ann-arbor.mi.us>
  7. Date: Thu, 24 Dec 1992 00:43:54 GMT
  8. References: <1406@minya.UUCP>
  9. Organization: The Programmer's Pit Stop, Ann Arbor MI
  10. Keywords: DTR
  11. Lines: 55
  12.  
  13. In article <1406@minya.UUCP> jcsu@minya.UUCP (John Chambers) writes:
  14. >So is it possible for a Sys/V process that has a port open to forcibly
  15. >drop DTR? (If not, I have yet another entry in my list of reasons that
  16. >we should list variants of Sys/V as unacceptable for the project.  ;-)
  17. >Might it be documented anywhere?
  18.  
  19. Try the termio(7) manpage.  On my SVR4 (Esix 4.0.3), it says this:
  20.  
  21.      The CBAUD bits specify the baud rate.  The zero  baud  rate,
  22.      B0,  is used to hang up the connection.  If B0 is specified,
  23.      the data-terminal-ready signal is not  asserted.   Normally,
  24.      this  disconnects the line.
  25.  
  26. In addition, termios(2) has this to say:
  27.  
  28.      cfsetospeed sets the output baud rate stored in the  termios
  29.      structure  pointed  to by termios_p to speed.  The zero baud
  30.      rate, B0, is used to terminate the  connection.   If  B0  is
  31.      specified,   the  modem  control  lines  are  no  longer  be
  32.      asserted.  Normally, this disconnects the line.
  33.  
  34. So, you could do something like this to disconnect the line:
  35.  
  36.     struct termios tty;
  37.     int fd;
  38.     /* ... */
  39.     tcgetattr(fd, &tty);        /* get current parameters */
  40.     cfsetospeed(&tty, 0);        /* set speed = 0 */
  41.     tcsetattr(fd, TCSAFLUSH, &tty); /* write parameters */
  42.  
  43. Or, if you're using termio instead of termios:
  44.  
  45.     struct termio tty;
  46.     int fd;
  47.     /* ... */
  48.     ioctl(fd, TCGETA, &tty);    /* get current parameters */
  49.     tty.c_cflag &= ~CBAUD;        /* turn off all speed flags */
  50.     tty.c_cflag |= B0;        /* set speed = 0 */
  51.     ioctl(fd, TCSETAF, &tty);    /* write parameters */
  52.  
  53. Or, you can use the new termios modem-control ioctls:
  54.  
  55.     int fd;
  56.     /* ... */
  57.     ioctl(fd, TIOCMBIC, TIOCM_DTR);    /* turn off DTR */
  58.  
  59. See, there are lots of ways of doing it under SVR4 or any other
  60. POSIX-compliant OS.  And at least one way of doing it under SVRx,
  61. where x <= 3.
  62.  
  63. -- 
  64. Marc Unangst, N8VRH         | "Of course, in order to understand this you
  65. mju@mudos.ann-arbor.mi.us   |  have to remember that the nucleus of the atom
  66.                             |  is squishy."
  67.                             |    -W. Scheider, from a Physics lecture
  68.