NetMF – Serial Port - Echo response App
Some people ask me to have any soft start guide using microframework serial port. Well, as you know in desktop apps is the typical “Hello World”, the translation into serial port apps are “Echo for response”.
This code shows how to open the serial port to read incoming bytes and resend it as an echo. Is the first brick to check that the UART is all right! After this lab, you are ready to build your own DCE/DTE protocol and play serial commands between both sides.
Private WithEvents SerialComm As SerialPort =
New SerialPort("COM1", 9600, Parity.None, 8, StopBits.One)
Private DataReceived As String = ""
Private PortActivity As New OutputPort(CType(55, Cpu.Pin), False)
' include your functions here
Private Sub SerialIn() Handles SerialComm.DataReceived
Dim Length As Integer = SerialComm.BytesToRead
Dim Frame(Length) As Byte
SerialComm.Read(Frame, 0, Length)
SerialComm.Write(Frame, 0, Length)
DataReceived = ""