0

我有一个 valentine 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 &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 &HEA &H31 &H09 &H73 &H73 &H00 &H00 &H00 &H0A &H00 &H00 &H96 &HAB &HE6 &H7F &H7F &H0F &HAA &HD8

V1 的数据表是: 在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

ESP 的完整 PDF 可以在这里找到

我看到了 &HAA(start) 和 &HD8(end) 但我如何在不继续添加的情况下将这些开始和结束分开?

4

0 回答 0