Serial Port Complete - Latest Microcontroller projects

(lily) #1
Using .NET’s SerialPort Class

 dim portData as String


If (Not (myComPort Is Nothing)) Then
If (Not myComPort.IsOpen) Then
myComPort.Open()
End If
End If

If myComPort.IsOpen Then
myComPort.ReadLine(portData)
myComPort.WriteLine(portData)
End If

 String portData;


if (!(ComPort.selectedPort == null))
{
if (!myComPort.IsOpen)
{
myComPort.Open();
}
}
if (ComPort.selectedPort.IsOpen )
{
portData = myComPort.ReadLine();
myComPort.WriteLine(portData ) ;
}

1 3  
65


Many applications send and receive data stored in byte arrays and read data into
byte arrays or byte variables.
Free download pdf