title: quickly toggle RTS manually when RTS_CONTROL_TOGGLE is enabled
body: <p>On Windows XP, I've got a standard (on the motherboard) RS-232 serial port opened and configured with </p>
  
  <pre><code>dcb.fRtsControl = RTS_CONTROL_TOGGLE;
  </code></pre>
  
  <p>This works fine for my needs.</p>
  
  <p>Now while there is no RX pending, I sometimes need to briefly toggle the RTS line under the control of my application.  I can't just call EscapeCommFunction, as that fails when RTS_CONTROL_TOGGLE is enabled. </p>
  
  <p>I tried to this:</p>
  
  <pre><code>dcb.fRtsControl = RTS_CONTROL_ENABLE; // manual RTS control and turns on RTS
  SetCommState( hDevice, &amp;dcb );
  dcb.fRtsControl = RTS_CONTROL_TOGGLE; // turns off RTS since there is no TX pending
  SetCommState( hDevice, &amp;dcb );
  </code></pre>
  
  <p>However, this never seems to work. I never see RTS toggle.  It's like the device driver notices that I just set RTS and am clearing it now, so it just aborts what I was doing. </p>
  
  <p>If I put a sleep in there:</p>
  
  <pre><code>dcb.fRtsControl = RTS_CONTROL_ENABLE; // turn on RTS
  SetCommState( hDevice, &amp;dcb );
  Sleep(1);
  dcb.fRtsControl = RTS_CONTROL_TOGGLE; // turns off RTS since there is no TX pending
  SetCommState( hDevice, &amp;dcb );
  </code></pre>
  
  <p>Then I see the toggle, but it's extremely variable in length, anywhere from 1 to 15 ms (which is to be expected I guess).  I use timeBeginPeriod to setup 1ms scheduling and my thread is already high priority (should I go to real time priority?). </p>
  
  <p>So, is there something I can to do "flush" the RTS change to the hardware so I don't have to do the Sleep?  I can busy wait (using QueryPerformanceCounter to wait for the amount of time I want), but I'm concerned that this would still not "flush" the RTS change to the device.</p>
  
  <p>Thanks.</p>