简体   繁体   中英

how to control dcd in linux

How to control data carrier detect's voltage? I use TIOCMSET , but it does not work:

int status;
int fd;
/* OPEN Connection */
if ((fd = open("/dev/ttyS0",O_RDWR)) < 0)
{
    printf("Couldn't open ttyS0\n");
    exit(1);
}
// turn on DCD
status |= TIOCM_CAR;
ioctl(fd, TIOCMSET, &status);

The voltage never changes on dcd pin, but the dtr and rts pin's voltage change. Can I do this in linux?

No, you cannot do that.

DCD is an output from Data Communication Equipment (like a modem) and an input to Data Terminal Equipment such as your typical computer.

An input can be read, but not driven.

The exception would be if you are running linux on something like an embedded board designed to be a peripheral, where its serial port might be wired as DCE rather than DTE, to permit direct connection to a PC without a null modem cable. However, in this case the signal you drive will probably not be called DCD in software, unless the soft interface also reflects the DCE role.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM