coleman@cam.nist.gov (Sean Sheridan Coleman X5672) (04/23/91)
I am working on a program that uses the tty serial lines. i would like to be able from my program to sense if the DCE (Data Communication Equipment) is at the other end and running, ie i dont want to have the program connect to a port that has nothing plugged into it. Is there a way to see if DATA CARRIER DETECT is high at the DCE end from a C program. Thanks in advanced` Sean Coleman NIST coleman@bldrdoc.gov
rbj@uunet.UU.NET (Root Boy Jim) (04/24/91)
coleman@cam.nist.gov (Sean Sheridan Coleman X5672) writes: >I am working on a program that uses the tty serial lines. i >would like to be able from my program to sense if the DCE (Data >Communication Equipment) is at the other end and running, ie >i dont want to have the program connect to a port that has >nothing plugged into it. Is there a way to see if DATA CARRIER >DETECT is high at the DCE end from a C program. If there is no carrier, you won't be able to open the port. Just poll each device (with open(dev,O_NDELAY) every so often. Or you can get trickier. Fork a child for each device you want to open. The child will block on the open. When the carrier comes on, the open will succeed. Have the child exit, which will then send a death of child signal to the parent. The parent will then open the device (in non blocking mode, just in case). -- [rbj@uunet 1] stty sane unknown mode: sane
trevc@tecate.mips.com (Trevor Cotton) (04/24/91)
In article <8272@alpha.cam.nist.gov>, coleman@cam.nist.gov (Sean Sheridan Coleman X5672) writes: |> I am working on a program that uses the tty serial lines. i |> would like to be able from my program to sense if the DCE (Data |> Communication Equipment) is at the other end and running, ie |> i dont want to have the program connect to a port that has |> nothing plugged into it. Is there a way to see if DATA CARRIER |> DETECT is high at the DCE end from a C program. |> |> |> Thanks in advanced` |> |> Sean Coleman |> NIST |> coleman@bldrdoc.gov If your OS has Berkeley functionality you should be able to use the TIOCMGET ioctl. -- --trevc--
peter@ficc.ferranti.com (Peter da Silva) (04/25/91)
In article <130199@uunet.UU.NET> rbj@uunet.UU.NET (Root Boy Jim) writes: > Or you can get trickier. > Fork a child for each device you want to open. The child > will block on the open. When the carrier comes on, the open > will succeed. Have the child exit, which will then send a > death of child signal to the parent. The parent will then > open the device (in non blocking mode, just in case). If the device on the other side (say, a modem) pays attention to DTR this will mess up: child issues open DTR raises Modem raises CD open completes child exits file descriptor closes DTR drops Modem drops carrier Oops. -- Peter da Silva. `-_-' peter@ferranti.com +1 713 274 5180. 'U` "Have you hugged your wolf today?"