title: C# Can't read full buffer from serial port Arduino
body: <p>I have Arduino connected to serial port. Arduino has the following simple code to send bytes:</p>
  
  <pre><code>void setup()
  {
      Serial.begin(9600);
  }
  
  void loop()
  {
      Serial.write((char)100);
  }
  </code></pre>
  
  <p>Code to receive bytes (in separate thread):</p>
  
  <pre><code>int buffersize = 100000;
  byte[] buffer = new byte[buffersize];
  
  SerialPort port = new SerialPort("COM3", 9600);
  port.ReadBufferSize = buffersize;
  port.Open();
  
  int bytesread = 0;
  do
  {
      bytesread = port.BytesToRead;
  }
  while(bytesread &lt; buffersize &amp;&amp; bytesread != buffersize);
  
  port.Read(buffer, 0, buffersize);
  </code></pre>
  
  <p>I read that BytesToRead can return more than ReadBufferSize because it includes one more buffer. But instead I can receive only nearly 12000 and after that ReadBufferSize doesn't change. The same problem occurs with all baud rates.  </p>
  
  <p>So how to read all 100000 bytes in buffer at once? Maybe there are some driver settings etc?
  Please help.</p>