coleman@cam.nist.gov (Sean Sheridan Coleman X5672) (04/24/91)
Is there a way from inside a C program to find out if DATA CARRIER DETECT is high on the Data communication devices? I want my program to see if there is a modem device on the other end of the cable before it tries to use that port. I am trying to make sure that the port plugged into the back of my Sparc Station is hooked into something. Thanks Sean Coleman NIST coleman@bldrdoc.gov
trevc@tecate.mips.com (Trevor Cotton) (04/30/91)
In article <8283@alpha.cam.nist.gov>, coleman@cam.nist.gov (Sean Sheridan Coleman X5672) writes: |> Is there a way from inside a C program to find out if |> DATA CARRIER DETECT is high on the Data communication devices? |> |> I want my program to see if there is a modem device on the |> other end of the cable before it tries to use that port. |> I am trying to make sure that the port plugged into the |> back of my Sparc Station is hooked into something. |> |> |> Thanks |> |> Sean Coleman |> NIST |> coleman@bldrdoc.gov Sun Release 4.0 Last change: 22 March 1989 20 TERMIO(4) DEVICES AND NETWORK INTERFACES TERMIO(4) TIOCMGET The argument is a pointer to an int. The current state of the modem status lines is fetched and stored in the int pointed to by the argument. This call is allowed from a background process.
les@chinet.chi.il.us (Leslie Mikesell) (04/30/91)
In article <8283@alpha.cam.nist.gov> coleman@cam.nist.gov (Sean Sheridan Coleman X5672) writes: >Is there a way from inside a C program to find out if >DATA CARRIER DETECT is high on the Data communication devices? >I want my program to see if there is a modem device on the >other end of the cable before it tries to use that port. >I am trying to make sure that the port plugged into the >back of my Sparc Station is hooked into something. First of all, a modem should not be asserting carrier detect unless it has a connection up with another modem. If you set it to keep carrier detect up all the time, then you can't tell when you actually have a connection. To test for carrier detect being asserted, all you have to do is set a short alarm and attempt an open. If the alarm hits before the open completes, you were blocked waiting for CD. Or, with Suns you can open with O_NDELAY and use their ioctl() extensions to retreive the modem status. Les Mikesell les@chinet.chi.il.us
wls@garden-brau.csd.uwm.edu (Bill Stapleton) (04/30/91)
In article <1991Apr29.211345.12615@chinet.chi.il.us>, les@chinet.chi.il.us (Leslie Mikesell) writes: > In article <8283@alpha.cam.nist.gov> coleman@cam.nist.gov (Sean Sheridan Coleman X5672) writes: ... > >I am trying to make sure that the port plugged into the > >back of my Sparc Station is hooked into something. ... > To test for carrier detect being asserted, all you have to do is > set a short alarm and attempt an open. If the alarm hits before > the open completes, you were blocked waiting for CD. Or, with > Suns you can open with O_NDELAY and use their ioctl() extensions > to retreive the modem status. This is probably obvious to all you experienced SUN people, but make sure you don't have the "soft carrier" stuff turned on. I helped hook a printer up to a new Sparc Station, and as shipped, the soft carrier for the tty port was locked on - So stuff would "print" whether the printer was on or off or unplugged or ... -- Bill Stapleton wls@csd4.csd.uwm.edu uwmcsd4!wls