Currently, I'm reading the CTS and DSR signals of a serial port in the following way:
bool get_cts(int fd) {
int s;
ioctl(fd, TIOCMGET, &s);
return (s & TIOCM_CTS) != 0;
}
Now I'd like to wait until get_cts()
returns true. A simple loop isn't the best solution I think (as it's extremely resource-intensive).
void wait_cts(int fd) {
while(1) {
if(get_cts(fd)) {
return;
}
}
}
Is there any better solution using C or C++ on Linux? (I cannot use any hardware flow control as I don't need the serial data lines at all.)