Marin D wrote:

> I need help on how to find out that the DCD line is on.
> 
> SHall I try opening in blocking mode
> 
>  fd = open("/dev/cua1", O_RDWR | O_NOCTTY);
> 
> and be sure that when the open() returns successfully the DCD is on?

You would need to use /dev/ttyS1 instead. The cu* devices are call-out
devices; they don't block on open().

Also, if something has done the equivalent of `stty -clocal', then the 
DCD line won't have any effect.

You might wish to use the function below instead.

-- 
Glynn Clements <[EMAIL PROTECTED]>


#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>

int modem_dcd(int fd)
{
        int status;

        if (ioctl(fd, TIOCMGET, &status) == -1)
        {
                perror("ioctl");
                return -1;
        }

        return status & TIOCM_CD;
}

Reply via email to