title: writing datastream wirh defined delay between each byte
body: <p>I need to send a constant data stream from a computer to a device. The device is connected to a ftdi-chip and the ftdi is communicating via usb with the computer. Unfortunately, at full speed, the device needs a delay between each transferred byte. </p>
  
  <p>Issue:</p>
  
  <p>At present I’m using WriteFile() with a hand written Delay (this is just a sample, not the full code):</p>
  
  <pre><code>for (i = 0; i &lt; size; i++)
  
  {
  
      WriteFile( m_hIDComDev, (LPSTR) &amp;ucByte, 1, &amp;dwBytesWritten, &amp;m_OverlappedWrite )
  
      QueryPerformanceCounter(&amp;start);
  
      QueryPerformanceCounter(&amp;stop);
  
      while (double(stop.QuadPart - start.QuadPart) &lt; DELAY)
      {
          QueryPerformanceCounter(&amp;stop);
      }
  }
  </code></pre>
  
  <p>Depending on the mood of my machine, this delay differs between 100 us and nearly 1s. I use a Scope to display the delay at the ftdi output. </p>
  
  <p>Question:</p>
  
  <p>Is there a way to configure the com port or the ftdi with a defined delay between each byte?
  With over words, getting rid of the “for” and use WriteFile with the size of the data instead of 1.</p>
  
  <p>Alternatively, does anyone know a different way, which fits?</p>
  
  <p>Limitation:</p>
  
  <p>The whole Program should be time optimized. The device can run with 230,4kBaud. Running with lower speed (38,4kBaud) already solves the problem. However, the overall time is too long. </p>
  
  <p>Programming in C using Visual Studio.</p>