Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ames!sdcsvax!rmr From: rmr@sdcsvax.UCSD.EDU (Robert Rother) Newsgroups: comp.bugs.sys5 Subject: Re: CLOCAL, or catch-22 Message-ID: <3607@sdcsvax.UCSD.EDU> Date: Thu, 6-Aug-87 21:52:53 EDT Article-I.D.: sdcsvax.3607 Posted: Thu Aug 6 21:52:53 1987 Date-Received: Sat, 8-Aug-87 15:02:24 EDT References: <325@nsta.UUCP> Reply-To: rmr@sdcsvax.UCSD.EDU (Robert Rother) Distribution: world Organization: U.C. San Diego Lines: 25 Keywords: O_NDELAY, CLOCAL, fcntl, termio Summary: Look into O_NDELAY on open. In article <325@nsta.UUCP> amos%nsta@nsc.com (Amos Shapir) writes: >One of the optional flags of the c_cflag field of termio is CLOCAL. (see >) It is supposed to cause the tty driver to ignore the >'carrier detect' bit in the RS232 interface, and open the line anyway. >This is needed for ports that do not have the DC wired; trying to open >such a port without setting the CLOCAL bit first, will cause the open to >hang forever waiting for a carrier signal. > >However, the only way to set this flag is by a ioctl call; the ioctl >call needs a file-descriptor argument; a file-descriptor can only be >obtained by a successfull open call... > >The only solution if you don't have sources is to re-wire all your >terminal plugs by shorting CD to DTR or something like that. The solution is to open the file with the O_NDELAY bit set (eg. fd = open(file, O_RDWR | O_NDELAY)). O_NDELAY allows the open to complete without waiting for carrier. Next, do a TCGETA ioctl to get the current settings (ioctl(fd, TCGETA, &term)), turn on the CLOCAL flag (term.c_flag |= CLOCAL) and do a TCSETA ioctl. Now the port is open and modem control lines will be ignored. -------------------------------------------- Robert (ain't got no cute sayings in my signature) Rother rmr@sdcsvax.UCSD.EDU or sdcsvax!rmr