我有一个与设备的串行连接,但无法处理来自设备的响应。
如果我使用超级终端并将命令发送TIME
到设备,我会得到如下响应;
TIME:13:30:30
这将继续在同一行更新。当我尝试使用我的应用程序执行此操作时,取决于我是使用 RTB 还是 TB 来显示响应,我会得到;
实时出价;
TIME:13:30:30
TIME:13:30:31
TIME:13:30:32
TIME:13:30:33
TIME:13:30:34
或结核病;
TIME:13:30:30TIME:13:30:31TIME:13:30:32TIME:13:30:33TIME:13:30:34
代码是;
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal [text] As String)
If Me.RichTextBox1.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
RichTextBox1.AppendText([text])
TextBox1.AppendText([text])
End If
End Sub
有什么方法可以得到与使用超级终端时相同的响应?