title: automatically changing RTS for RS-485 communication
body: <p>I'm trying to setup half duplex communication in my program. I have my RS485 transceiver using the RTS flag (TIOCM_RTS) to toggle back and forth between transmit and receive. And to send/receive data I need to change RTS flag manually:</p>
  
  <ol>
  <li><p>Set RTS to High.</p></li>
  <li><p>Send data.</p></li>
  <li><p>Set RTS to low.</p>
  
  <pre><code>int setRTS(int level) {
      int status;
      ioctl(ser_port, TIOCMGET, &amp;status);
      if(level) {
          status |= TIOCM_RTS;
      } else {
          status &amp;= ~TIOCM_RTS;
      }
      ioctl(ser_port, TIOCMSET, &amp;status);
      return 1;
  }
  </code></pre></li>
  </ol>
  
  <p>My question is: shouldn't the linux kernel be able to switch RTS automatically? 
  And how to ensure that data was sent before calling setRTS(0)?</p>