title: Serial programming (hardware handshake)
body: <p>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:</p>
  
  <pre><code>int setCTS(int fd, int value) {
      int status;
      ioctl(fd, TIOCMGET, &amp;status); // get the current port status
      if (value)
          status |= TIOCM_CTS; // rise the CTS bit
      else
          status &amp;= ~TIOCM_CTS; // drop the CTS bit
      ioctl(fd, TIOCMSET, $status); // set the modified status
      return 0;
  }
  </code></pre>
  
  <p>where <em>fd</em> is the file descriptor for the port and <em>value</em> is the value to be set for the signal. To code this function I based on <a href="http://www.easysw.com/~mike/serial/serial.html#5_1" rel="nofollow noreferrer">http://www.easysw.com/~mike/serial/serial.html#5_1</a>.</p>
  
  <p>The problem is that <em>gcc</em> does not recognize any of the constants used in the example. Any suggestions?</p>
  
  <p>-- Update --</p>
  
  <p>I've found an answer. Looking to another example, <code>sys/ioctl.h</code> declares the constants.</p>