Com端口数据发送问题

时间:2014-02-22 13:36:43

标签: vb.net serial-port led

我发送数据,即12345到与我的COM端口连接的LED显示器,但它在LED上显示12344而不是12345.I已通过Hyperterminal检查,发现LED显示屏没有问题。 我的代码最后自己添加了“4”。在这个问题上需要帮助

我的代码:

  With comPort


            '.ParityReplace = &H3B                    ' replace ";" when parity error occurs 

            .BaudRate = 9600
            .Parity = IO.Ports.Parity.None
            .DataBits = 8
            .StopBits = IO.Ports.StopBits.One
            .Parity = IO.Ports.Parity.None
            '.Handshake = IO.Ports.Handshake.None
            '.RtsEnable = False
            '.ReceivedBytesThreshold = 1             'threshold: one byte in buffer > event is fired 
            '.NewLine = vbCr         ' CR must be the last char in frame. This terminates the SerialPort.readLine 
            '.ReadTimeout = 10000


        End With


        Try

            comPort.Close()
            If comPort.IsOpen = False Then
                comPort.Open()
            End If
            Dim a As String = ""
            For i As Integer = 0 To 4

                comPort.WriteLine("12345") ' & Char.Parse(32))
            Next



        Catch ex As Exception
            MsgBox("Error Open: " & ex.Message)
        End Try

0 个答案:

没有答案