Hi i am trying to write-read data from serial port but it don't work
my code look like this

Private comPort As New SerialPort

            comPort.PortName = cboCom.Text
            comPort.Parity = Parity.None
            comPort.DataBits = 8
            comPort.StopBits = StopBits.One
            comPort.BaudRate = CInt(cboSpeed.Text)
            comPort.Handshake = Handshake.None

 comPort.Open()
'Write GPS command
 comPort.WriteLine("$PSRF103,00,00,01,01*25")

and the result is my device don't listen and i dont know WHY!!

Hi i am trying to write-read data from serial port but it don't work
my code look like this

Private comPort As New SerialPort

            comPort.PortName = cboCom.Text
            comPort.Parity = Parity.None
            comPort.DataBits = 8
            comPort.StopBits = StopBits.One
            comPort.BaudRate = CInt(cboSpeed.Text)
            comPort.Handshake = Handshake.None

 comPort.Open()
'Write GPS command
 comPort.WriteLine("$PSRF103,00,00,01,01*25")

and the result is my device don't listen and i dont know WHY!!

I find it!
the problem was on the line
comPort.Writeline("fdsfsdfsdfa")
and the correct is
comPort.Write("fsdfsdfsda" + vbCrLf)
thanks anyway

Ok but my program is very slow now
it take too much time to display the serial data to the listbox
is any better method to do this?
please advice me

Private comPort As New SerialPort
      comPort.PortName = cboCom.Text
      comPort.Parity = Parity.None
      comPort.DataBits = 8
      comPort.StopBits = StopBits.One
      comPort.BaudRate = CInt(cboSpeed.Text)
      comPort.Handshake = Handshake.None
      comPort.ReadTimeout = 1000
      comPort.WriteTimeout = 1000
      comPort.Open()


 Private Sub query_GGA()
        comPort.Write("$PSRF103,00,01,00,01*25" + vbCrLf)
        gga_string = comPort.ReadLine
        ListGPS.Items.Add(gga_string)
    End Sub

    Private Sub query_GLL()
        comPort.Write("$PSRF103,01,01,00,01*24" + vbCrLf)
        gll_string = comPort.ReadLine
        ListGPS.Items.Add(gll_string)
    End Sub
    Private Sub query_GSA()
        comPort.Write("$PSRF103,02,01,00,01*27" + vbCrLf)
        gsa_string = comPort.ReadLine
        ListGPS.Items.Add(gsa_string)
    End Sub
    Private Sub query_GSV()
        comPort.Write("$PSRF103,03,01,00,01*26" + vbCrLf)
        gsv_string(0) = comPort.ReadLine
        gsv_string(1) = comPort.ReadLine
        gsv_string(2) = comPort.ReadLine
        ListGPS.Items.Add(gsv_string(0))
        ListGPS.Items.Add(gsv_string(1))
        ListGPS.Items.Add(gsv_string(2))
    End Sub
    Private Sub query_RMC()
        comPort.Write("$PSRF103,04,01,00,01*21" + vbCrLf)
        rmc_string = comPort.ReadLine
        ListGPS.Items.Add(rmc_string)
    End Sub
    Private Sub query_VTG()
        comPort.Write("$PSRF103,05,01,00,01*20" + vbCrLf)
        vtg_string = comPort.ReadLine
        ListGPS.Items.Add(vtg_string)  
    End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        query_GGA()
        query_GLL()
        query_GSA()
        query_GSV()
        query_RMC()
        query_VTG()
    End Sub

Edited 6 Years Ago by iamai: nothing

This article has been dead for over six months. Start a new discussion instead.