GPS - Decode event not firing

Discussion in 'Questions (Windows Mobile)' started by daveo84, Sep 28, 2008.

  1. daveo84

    daveo84 Member Licensed User

    I've been trying to have a GPS_Decode event fire now for nearly a day...Using the examples listed on the homepage (downloads section/gps example) I've tried connecting a GPS (Delorme Earthmate) to the Serial Port, two freeware GPS simulator devices (from another PC to this PC). And Testing on a pocket PC. All of them connect and receive data but the event doesn't fire. I've been very mindful of the port settings/baud rate/ etc.

    I know it is connecting because I receive values for Serial.Inputstring when I'm debugging. GPS.tostring returns Decode_GPS.GPS or something like that...(I've been up for nearly 22 hours now straight and am going to go take a nap). I also made sure the Sub Functions were names appropriately and coincide with the GPS varialbe name.

    Thanks in advance for any help!
  2. agraham

    agraham Expert Licensed User

    The name of the event is actually "GPSDecoded", are you using the correct Sub name? Your event Sub should be called "Sub GPSobjectname_GPSDecoded".
  3. daveo84

    daveo84 Member Licensed User

    Exactly as it show in the examples.... I get the same problem running them as is without altering any of the Sub names. I am also making sure all of the objects are created and appropriate libraries have been added.
  4. agraham

    agraham Expert Licensed User

    Build up successive Serial.InputString contents in a multi-line textbox or a string for a MsgBox and have a look at it. The GPS library wants a GPRMC sentence terminated by a Cr and Lf and a GPGGA sentence also terminated by Cr and LF in its buffer before decoding it. Check you are getting both of those.
  5. daveo84

    daveo84 Member Licensed User

    Ok, so I made sure the line feeds and the returns were in the nmea data. I also watched the serial.inputstring and the data was exactly the same as the output from the sim we're using (Skylab GPS Simulator). It just sits there taking in the data and never gets beyond that.

    How long should it take before this event happens?
    Last edited: Sep 30, 2008
  6. agraham

    agraham Expert Licensed User

    It is fired by GPS.GPSStream(Serial.InputString). GPSStream fills a buffer appending successive strings passed to it and as soon as the buffer contains both sentences I specified above it parses the data and fires the event then clears the buffer for the next data.

    PS. "GPRMC" and "GPGGA" must be uppercase.
    Last edited: Sep 30, 2008
  7. daveo84

    daveo84 Member Licensed User


    I'll have a look again, I literally let it run for 10 minutes and still nothing. Both using Delorme Earthmate (actual GPS) and the simulator (figured I'd take out any issues of reception, etc). I've made sure the parity, baud rates, com specs on both ends, and all of the appropriate settings are correct.

    Thanks for the help.... I'll report back !
  8. daveo84

    daveo84 Member Licensed User

    NMEA data

    The following is a literal example of the data I get coming through the serial.inputstring:

    Except the Lf & Cr show up as □ in the code. (would this make a difference? ex: $GPGGA,021249,0000.0000,N,00000.0000,E,1,5,1.0,2000.0,M,0,M,,,,0000*66□□)




    It does take quit a while for the string to append a new line (3 lines took 90 seconds or so).

  9. Erel

    Erel Administrator Staff Member Licensed User

    Can you please save the data received to a file and upload the file?
    You should save GPS.GPSBuffer to a file after several minutes.
  10. daveo84

    daveo84 Member Licensed User

    Will do tommorow. Also I moved the example code to a pocket pc w/ windows mobile 6.1 and ran it there. No data was received from the buffer/inputstring. This was tested in a working environment (The system GPS was working fine and I had altered the code to fit the specific baud rate, port etc.)

    Thanks again!
  11. daveo84

    daveo84 Member Licensed User

    gps files

    I've attached part of the file I generated (the actual file when I left it running for over a minute was 150mb+ (6168 pages).
  12. daveo84

    daveo84 Member Licensed User

    Another chunk of the file

    Here is a larger segment (txt zipped up)

    Attached Files:

  13. agraham

    agraham Expert Licensed User

    There is nothing wrong with the data. I downloaded hello3b.txt and read it into a GPS object and events fire with no problem. This is not strictly comparable to your real data as I had to add the CRLF as a file read strips them off.

    I haven't attached an sbp file as I am running the next version beta which won't load on earlier versions. I think the test is valid as I don't think the GPS library has changed. You need a Form1 with a Timer1, a Textbox1, a Label1 and an ArrayList1 . You also need a GPS object.

    EDIT: - I should clarify that it works on both my device (Axim X30, WM2003, no internal GPS) and my desktop.

    Sub Globals
    'Declare the global variables here.
       Line = 0
    End Sub

    Sub App_Start
    If FileExist (AppPath & "\hello3b.txt") = True Then
          FileOpen (c1,AppPath & 
    "\hello3b.txt",cRead ,, cASCII)
          r = FileRead (c1)
    Do Until r = EOF
             s = r & 
          r = FileRead (c1) 
          FileClose (c1)
    End If
       Timer1.Interval = 
       Timer1.Enabled = 
    End Sub

    Sub Timer1_Tick
       label1.Text = line
       line = line + 
    If Line = arraylist1.Count Then
       line = 
    End If
    End Sub

    Sub GPS_GPSDecoded
       textbox1.Text = line
    End Sub
    Last edited: Oct 2, 2008
  14. derez

    derez Expert Licensed User

    Text file of GPS ?

    Sorry to tell you guys, the large file contains the same three lines over and over again (with the same time - its the same string).
    the data there is of a GPS which does not have coordinates yet, and I don't know what you decoded - may be this is the problem.
  15. agraham

    agraham Expert Licensed User

    No, if I replay that data into my test program it also fires events.
  16. agraham

    agraham Expert Licensed User

    I suspect that the problem is with the CR LF pairs that the library expects. I have looked directly into those files with a Hex Editor. I don't know how you recorded that data but in hello3b.txt the data lines seem to be terminated by either a single LF or by a LF CR pair. If this was input as-is into the library it would not cause events to fire as the library requires CR LF pairs which are not present in this data but are added by my test program.

    GPS2.Txt does seem to have lines separated by CR LF pairs so I would have expected if this data was fed as-is into the library it should have workd.
  17. Erel

    Erel Administrator Staff Member Licensed User

    I suspected this as well.
    A proper nmea sentence should end with the two characters.
  18. daveo84

    daveo84 Member Licensed User


    Thanks guys, got it working!

    You're the best!
  19. agraham

    agraham Expert Licensed User

    Thanks but you could at least tell us what the problem was :confused:
  20. daveo84

    daveo84 Member Licensed User

    Kind of working

    After appending a line feed to the serialinputstring .... (SEE BELOW)

    Everything seemed to be fine on the desktop. However, after compiling a device exe file and sending it over the phone (PPC 6800). The example just opens the serial port and the device never seems to acknowledge that there is any sort of data streaming in. The "GPS was disconnected." messagebox is the only result. I've again gone through the code and altered all of the serail port settings / baudrates, (Erel I even used the code examples you posted to read the registry for COM port access to confirm the correct settings). The navigational software included from Sprint works and I can see the same settings are applied for this example. Port 4, baudrate 4800.


    So, I've had the desktop code working but not on the ppc.

    Sub Timer1_Tick

    If Serial1.InBufferCount > 0 Then
    Label1.Text = "GPS is connected."

    GPS1.GPSStream(Serial1.InputString & CRLF)

    textbox1.Text = textbox1.Text & serial1.InputString

    counter = 0
    counter = counter + 1
    If counter >= 5 Then 'After 5 seconds without any data we will try to make a new connection.
    counter = 0
    Timer1.Enabled = false
    Serial1.PortOpen = false
    Label1.Text = "No connection."
    GPS1.GPSBuffer = ""
    If Msgbox("GPS was disconnected." & crlf & "Do you want to reconnect?","",cMsgboxYesNo) = cYes Then
    mnuConnect_Click 'Try to reconnect.
    End If
    End If

    End If

    End Sub
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice