I am trying to read the following data from 4 serial ports in VB.Net 2012
00056
00056
00056
00056
00056
Its 5 lines of data. The starting digit is a space and there are four lines of data. I have tried so many different code but none has worked. I have searched only and had no success. All the samples I have seen talks to only one serial port. My newest code is as follows which I got from a Microsoft website. If I call this function 4 times will it work?
Thanks,
Shaminda
00056
00056
00056
00056
00056
Its 5 lines of data. The starting digit is a space and there are four lines of data. I have tried so many different code but none has worked. I have searched only and had no success. All the samples I have seen talks to only one serial port. My newest code is as follows which I got from a Microsoft website. If I call this function 4 times will it work?
Code:
Public Function ReceiveSerialDataPort8() As String
' Receive strings from a serial port.
Dim returnStr As String = ""
Dim com1 As IO.Ports.SerialPort = Nothing
Try
com1 = My.Computer.Ports.OpenSerialPort("COM8", 9600, Parity.None, 8, StopBits.One)
com1.ReadTimeout = 10000
Do
Dim Incoming As String = com1.ReadLine()
If Incoming Is Nothing Then
Exit Do
Else
returnStr &= Incoming & vbCrLf
End If
Loop
Catch ex As TimeoutException
returnStr = "Error: Serial Port read timed out."
Finally
If com1 IsNot Nothing Then com1.Close()
End Try
Return returnStr
End Function
Thanks,
Shaminda