Hello, everyone,
Currently, I have an simple serial communication application using the
serialnet.dll tool from Franson company. What this application does is
to read the data through the com port in my windows ce 5 based
wearable computer. The data is sent from a PIC microcontroller through
the RS232 protocol. The scenario is like whenever you press a button,
my PIC will detect the trigger and then send a single data through
RS232 port to the wearable computer.
Using the serialnet.dll file, I can read the data and show the data in
a textbox.
The code is like when you set the
objPort.Enabled = True
whenever there is data coming from the com port, the objPort.OnRead
event will trigger the following code
Private Sub objPort_OnRead( ByVal Data As String) Handles
objPort.OnRead
If Data Is Nothing Then
txtRead.Text = "Timeout"
Else
txtRead.Text = Data
End If
End Sub
And I have another simply application which adopt the TcpClient in net
cf. This part of the application can send data from the wearable
computer to the desktop PC. The main code is like the following,
Dim serverIP As IPAddress
serverIP = IPAddress.Parse (ServerTextBox. Text)
' Try to connect to the server on port 10000
Dim client As New TcpClient
client.Connect( New IPEndPoint(serv erIP, 10000))
Dim startCode As [Byte]() = Encoding.ASCII. GetBytes("CONNE CT|
computer" & vbCrLf)
strm = client.GetStrea m()
strm.Write(star tCode, 0, startCode.Lengt h)
So my question is how can I send the data(from the com port) through
the TcpClient to the PC. The data within the objPort_OnRead( ) method
is not visible to other method. I don't know how to bind this data to
the TcpClient.GetSt ream.write() method.
I am still new to Visual Basic .net and .net cf. Could somebody give
me some instructions on how to solve this?
Best wishes,
Currently, I have an simple serial communication application using the
serialnet.dll tool from Franson company. What this application does is
to read the data through the com port in my windows ce 5 based
wearable computer. The data is sent from a PIC microcontroller through
the RS232 protocol. The scenario is like whenever you press a button,
my PIC will detect the trigger and then send a single data through
RS232 port to the wearable computer.
Using the serialnet.dll file, I can read the data and show the data in
a textbox.
The code is like when you set the
objPort.Enabled = True
whenever there is data coming from the com port, the objPort.OnRead
event will trigger the following code
Private Sub objPort_OnRead( ByVal Data As String) Handles
objPort.OnRead
If Data Is Nothing Then
txtRead.Text = "Timeout"
Else
txtRead.Text = Data
End If
End Sub
And I have another simply application which adopt the TcpClient in net
cf. This part of the application can send data from the wearable
computer to the desktop PC. The main code is like the following,
Dim serverIP As IPAddress
serverIP = IPAddress.Parse (ServerTextBox. Text)
' Try to connect to the server on port 10000
Dim client As New TcpClient
client.Connect( New IPEndPoint(serv erIP, 10000))
Dim startCode As [Byte]() = Encoding.ASCII. GetBytes("CONNE CT|
computer" & vbCrLf)
strm = client.GetStrea m()
strm.Write(star tCode, 0, startCode.Lengt h)
So my question is how can I send the data(from the com port) through
the TcpClient to the PC. The data within the objPort_OnRead( ) method
is not visible to other method. I don't know how to bind this data to
the TcpClient.GetSt ream.write() method.
I am still new to Visual Basic .net and .net cf. Could somebody give
me some instructions on how to solve this?
Best wishes,