title: C# and SerialPort Class truncating data
body: <p>I have a C# application that uses the .NET SerialPort class. The code that I use to pick up data from the serial port is nothing special. The key parts are</p>
  
  <pre><code>//Open the port
              comport.BaudRate = myPort.BaudRate;
              comport.StopBits = StopBits.One;
              comport.DataBits = 8;
              comport.Parity = Parity.None;
              comport.ReadTimeout = 20000;
  
  
              comport.PortName = myPort.PortSystemName;
              comport.Handshake = Handshake.None;
              comport.RtsEnable = true;
  
  
              comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
  comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
  
      private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
          {
  
              string msg = "";
              try
              {
                  msg = comport.ReadExisting();
  
                  if (comport.IsOpen)
                      comport.Close();
           }
  </code></pre>
  
  <p>This code works <strong>perfectly fine in Windows XP</strong>. However, on Windows 7 it runs into issues where no matter what data is sent, it ONLY picks up the first four characters. So in a string like "123456", the msg will be "1234". The device that is collecting the data is an RFIdeas pcProx and I have verified that the data is just fine. I have also verified that the data looks OK in hyperterminal. So there has to be something odd about the way that I'm picking up the data in code. Help!</p>