我有一个情人1雷达以及V1Connect(蓝牙适配器),它通过虚拟串行端口(COM 16)连接到我的PC。
我正在尝试阅读来自它的数据,但我得到的只是胡言乱语。
我的VB.net代码是这样的:
Private pendingMsg As New stringbuilder
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each s In System.IO.Ports.SerialPort.GetPortNames()
lstPorts.Items.Add(s)
Next s
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim b As Integer
SerialPort1.ReadTimeout = 50
Try
Do While SerialPort1.BytesToRead > 0
b = SerialPort1.ReadByte
Me.BeginInvoke(New mydel(AddressOf txt_out), b)
Loop
Catch ex As Exception
End Try
End Sub
Private Sub txt_out(ByVal i As Integer)
txtReceived.AppendText("&H" & i.ToString("X2") & " ")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SerialPort1.BaudRate = 57600
SerialPort1.DataBits = 8
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.StopBits = IO.Ports.StopBits.One
SerialPort1.PortName = "COM16" 'lstPorts.SelectedItem.ToString
SerialPort1.Open()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SerialPort1.Close()
txtReceived.Text = ""
End Sub
输出是这样的:
&安培; H7F&安培; H0F&安培; HAA&安培; HD8&安培; HEA&安培; H31&安培; H09&安培; H00&安培; H00&安培; H00&安培; H00&安培; H00&安培; H0A&安培; H00&安培; H00&安培; HB0&安培; HAB&安培; H1a和H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8&安培; HEA&安培; H31&安培; H09&安培; H00&安培; H00&安培; H00&安培; H00&安培; H00&安培; H0A&安培; H00&安培; H00&安培; HB0&安培; HAB&安培; H1a和H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8&安培; HEA&安培; H31&安培; H09&安培; H00&安培; H00&安培; H00&安培; H00 &安培; H00&安培; H0A&安培; H00&安培; H00&安培; HB0&安培; HAB&安培; H1a和H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8&安培; HEA&安培; H31&安培; H09&安培; H00&安培; H00&安培; H00&安培; H00&安培; H00&安培; H0A&安培; H00&安培; H00&安培; HB0&安培; HAB&安培; H1a和H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8&安培; HEA&安培; H31&安培; H09&安培; H00&安培; H00&安培; H00&安培; H00&安培; H00&安培; H0A&安培; H00&安培; H00&安培; HB0&安培; HAB&安培; H1a和H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8 &安培; HEA&安培; H31&安培; H09&安培; H73&安培; H73&安培; H00&安培; H00&安培; H00&安培; H0A&安培; H00&安培; H00&安培; H9 6安培; HAB&安培; HE6&安培; H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8&安培; HEA&安培; H31&安培; H09&安培; H73&安培; H73&安培; H00&安培; H00&安培; H00&安培; H0A&安培; H00&安培; H00&安培; H96&安培; HAB&安培; HE6&安培; H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8&安培; HEA&安培; H31&安培; H09&安培; H73&安培; H73&安培; H00&安培; H00 &安培; H00&安培; H0A&安培; H00&安培; H00&安培; H96&安培; HAB&安培; HE6&安培; H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8&安培; HEA&安培; H31&安培; H09&安培; H73&安培; H73&安培; H00&安培; H00&安培; H00&安培; H0A&安培; H00&安培; H00&安培; H96&安培; HAB&安培; HE6&安培; H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8&安培; HEA&安培; H31&安培; H09&安培; H73&安培; H73&安培; H00&安培; H00&安培; H00&安培; H0A&安培; H00&安培; H00&安培; H96&安培; HAB&安培; HE6&安培; H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8 &安培; HEA&安培; H31&安培; H09&安培; H73&安培; H73&安培; H00&安培; H00&安培; H00&安培; H0A&安培; H00&安培; H00&安培; H96&安培; HAB&安培; HE6&安培; H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8&安培; HEA&安培; H31&安培; H09&安培; H73&安培; H73&安培; H00&安培; H00&安培; H00&安培; H0A &安培; H00&安培; H00&安培; H96&安培; HAB&安培; HE6&安培; H7F&安培; H7F&安培; H0F&安培; HAA&安培; HD8
V1的数据表是:
可以找到ESP的完整PDF here
我看到& HAA(开始)和& HD8(结束),但我如何分开这些开始和结束而不继续添加?