title: high-speed uart in python
body: <p>I have a microcontroller that sends data via UART at 3 MBaud. The microcontroller sends a start/status Byte every 8000 Bytes. I d'like my python script to read all data and analyse the data between the start bytes. </p>
  
  <p>I know that Python is able to handle 3 MBaud since that code snippet shows the correct positions of start bytes:</p>
  
  <pre><code>ser =  serial.Serial('COM3', 3000000, timeout=None)
  
  _RawData = ser.read(100000)
  
  for cnt in range(0, 100000, 1):
      #search for start byte and print the position    
      if(_RawData[cnt] &lt; 128): print(cnt)
  </code></pre>
  
  <p>But I need to constantly read the data stream, with that example I loose data between the "ser.read(x)" commands. So I need to compare the data while reading the stream:</p>
  
  <pre><code>ser =  serial.Serial('COM3', 3000000, timeout=None)
  
  _RawData = []
  cnt = 0
  
  for c in ser.read():   
      cnt += 1 
      #search for start byte    
      if(c &lt; 128):
          #print start byte position
          print(cnt)
  
          # -= start thread =-
  
          _RawData.clear()
      _RawData.append(c)
  </code></pre>
  
  <p>But found out that reading one single byte is too slow for that baudrate, the start byte position is practically randomly generated. Is there a way I can read my data stream, without loss?</p>