title: Data gets corrupted during transmission over the serial port
body: <p>I am developing a program to communicate with an old system. I use System.IO.Ports.SerialPort for this. The problem is when I send a longer message, the message bevome corrupt. I use a line listener and get the following results</p>
  
  <p>What I sending</p>
  
  <pre><code>aa 01 00 00 12 03 06 18 02 c1 94 02 c1 94 00 00 00 00 00 00 00 00 00 00 00 00 1e fd 
  </code></pre>
  
  <p>What I get</p>
  
  <pre><code>c2 aa 01 00 00 12 03 06 18 02 c3 81 c2 94 02 c3 81 c2 94 00 00 00 00 00 00 00 00 00 00 00 00 1e c3 bd
  </code></pre>
  
  <p>The code I'm using is</p>
  
  <pre><code>_comPort.Encoding = new UTF8Encoding();
  _comPort.PortName = PortName;  //Com1
  _comPort.BaudRate = BaudRate;  //9600
  _comPort.StopBits = StopBits;  //1
  _comPort.DataBits = DataBits;  //8
  _comPort.Parity   = Parity;    //None
  _comPort.Open();
  
  _comPort.Write(messageStr);
  </code></pre>
  
  <p>Why is data corrupted and how do I fix this?</p>