FYI. I tested this:
As I suspected it is subject to timeout errors for the reasons specified. You may not see the error, but it can happen. If you run the code at very low speeds, i.e. 1200bps, the error occurs more frequently. Just wanted to give you a heads up.Code:Public Delegate Sub mydelegate(ByVal a_string As String) Private Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived Dim arduino_string As String = String.Empty SerialPort1.ReadTimeout = 20 Try arduino_string = SerialPort1.ReadLine Me.Invoke(New mydelegate(AddressOf txt_out), arduino_string) Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub




Reply With Quote
