我有一个通过COM端口发送和接收数据的应用程序 这是接收数据的代码:
Private Sub ReceivedText(ByVal [text] As String) 'input pentru citire readexisting
If Me.rtbComData.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.rtbComData.Text &= [text] 'adauga text
Me.rtbComData.BackColor = Color.Green
End If
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
这是发送数据的代码。
SerialPort1.WriteLine("AT+DSCAN")
我只需要通过IP发送此类数据。
我需要连接到特定的IP并发送数据,然后将响应用于完整的富文本框。