Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27189

VS 2008 Receive Data from Serial Port

$
0
0
Hi to all:

I have an electronic board that send for SerialPort +/- 60 messages by Second...
I have no problem catch the messages when i work with potenciometers, by i have here problems with swicthes. The swicth have a value, one for example, and when i press the swicht the value change for 2 momentary, that's mean return to 1 after press...
I need to catch the number 2 (that's mean the user as press the swicht), and when this happen, a lot of times the pressing button as lost, i need to press and press and press until receive the signal!

This is my code that read the data coming from electronic board:


Code:

Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
          Me.Invoke(New EventHandler(AddressOf receber_Tramas))
    End Sub
    Private Sub receber_Tramas()

        trama_recebida = ""
        Trama_primeira_trama = ""

        Dim str1 As String
        Dim strarr() As String
        str1 = SerialPort1.ReadExisting.ToString
        strarr = str1.Split(" ")



        Trama_primeira_trama = Microsoft.VisualBasic.Left(str1, 4)

              Select Case Trama_primeira_trama
              Case "0041"
                'Manipular trama para receber do potenciómetro do TRIM
                trama_recebida = strarr(0)
                trama_recebida = Microsoft.VisualBasic.Left(trama_recebida, 43)
                Trama_Apoio_Trim = Microsoft.VisualBasic.Mid(trama_recebida, 19, 4)

                'Manipular trama para receber do potenciómetro dos Flaps
                Trama_Apoio_Flaps = Microsoft.VisualBasic.Mid(trama_recebida, 15, 4)

                'Manipular trama para receber do potenciómetro dos Speed Brakes
                Trama_Apoio_Speed_Brakes = Microsoft.VisualBasic.Mid(trama_recebida, 11, 4)
        End Select


     

          End Sub


I need a little help here to resolve this problem!

Thanks

Viewing all articles
Browse latest Browse all 27189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>