I'm trying to to program a serial communication using hardware handshake in linux using C/C++. The signals that implement the handshake are CTS (Clear to send) and RTS (Request to send). Currently my function for setting the CTS signal looks as follows:
int setCTS(int fd, int value) {
int status;
ioctl(fd, TIOCMGET, &status); // get the current port status
if (value)
status |= TIOCM_CTS; // rise the CTS bit
else
status &= ~TIOCM_CTS; // drop the CTS bit
ioctl(fd, TIOCMSET, $status); // set the modified status
return 0;
}
where fd is the file descriptor for the port and value is the value to be set for the signal. To code this function I based on http://www.easysw.com/~mike/serial/serial.html#5_1.
The problem is that gcc does not recognize any of the constants used in the example. Any suggestions?
-- Update --
I've found an answer. Looking to another example, sys/ioctl.h
declares the constants.