title: Serial connection carriage return
body: <p>I'm creating a Hyperterminal type app in VB.NET and have a problem with the serial connection. When I send data to the device, I get the response I'm expecting but with an extra CR in the response. Ie if I send a command in Hyperterminal I get a response such as;</p>
  
  <pre><code>response one
  response two
  </code></pre>
  
  <p>But in my app it will return;</p>
  
  <pre><code>response one
  
  response two
  </code></pre>
  
  <p>The code is as follows;</p>
  
  <pre><code>Private Sub textSend_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textSend.KeyPress
  
          If e.KeyChar = Convert.ToChar(Keys.Enter) Then 
  
              connSerial.Write(textSend.Text &amp; vbCr)
              textSend.Text = ""
  
              e.Handled = True 
  
          End If
  
      End Sub
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Private Sub connSerial_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles connSerial.DataReceived
          ReceivedText(connSerial.ReadExisting()) 
      End Sub
      Private Sub ReceivedText(ByVal [text] As String)
          If Me.textReply.InvokeRequired Then
              Dim x As New SetTextCallback(AddressOf ReceivedText)
              Me.Invoke(x, New Object() {(text)})
          Else
              textReply.AppendText([text])
          End If
  
      End Sub
  </code></pre>
  
  <p>I am using a 1200 baud rate and literally every line is seperated by another, however if I up the baud rate to 57600 it only happens occasionally. Ie;</p>
  
  <pre><code>response 1
  response 2
  response 3
  
  response 4
  response 5
  </code></pre>