determining if DCE device is ready

Root Boy Jim rbj at uunet.UU.NET
Wed Apr 24 07:06:28 AEST 1991


coleman at 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 at uunet 1] stty sane
		unknown mode: sane



More information about the Comp.unix.questions mailing list