Populates a GPSFix structure with data from the current position fix.
GPS and SerialGPS objects
Integer GPSname.GetFix ( myGPSFix )
Argument |
Description |
---|---|
GPSname |
Name of the GPS or SerialGPS object |
myGPSFix |
GPSFix structure object passed by reference that can store the data from the current position fix |
Integer. Returns 1 for success and 100 or a negative number for an error. The following is a list of possible error codes and their meanings:
-10 Invalid object. Could occur if the GPS object instance is corrupted.
-13 Not previously opened. This function cannot be called until a GPS object or SerialGPS object has been successfully opened.
-14 Read timeout. Occurs when the timeout interval (a ConfigParams property of the SerialGPS object) is exceeded.
-16 Parser Error. Parser is unable to interpret a sentence. This error is generated when nonstandard tokens are discovered while parsing the GPS data.
-17 Checksum Error. Most GPS sentences end in a two-digit checksum value. The PocketBuilder parser verifies this value and reports a checksum error if the calculated value does not match the stated value.
Use this function to populate a GPSFix structure with data about the current position fix, including data about the location of the fix and how reliable the data is. Each GetFix request obtains data from a different $GPGGA sentence in the data buffer. If the end of the data buffer is reached before finding a new sentence to parse, a GPS object returns 100 to indicate the end of the buffer has been reached. A SerialGPS object automatically reads in a new buffer and searches the new buffer. If this second data buffer does not contain a $GPGGA sentence, then the SerialGPS object returns 100.
The following lines create a SerialGPS object, retrieve information about the current position fix, test the validity of the GPSFix object, and write data to a multiline edit box:
SerialGps myGPS GPSFix myFix Real lr_alt, lr_gh, lr_hdop
Integer li_numsats, rc MyGPS = CREATE SerialGPS myGPS.Open() ... rc = MyGPS.GetFix(myFix) if rc = 1 then if myFix.IsFixValid then lr_alt = myFix.Altitude lr_gh = myFix.geoidalheight lr_hdop = myFix.HDOP mle_fix.text = "Recorded at: " + & String(myFix.FixTime) mle_fix.text += "Altitude: " + String(lr_Alt) mle_fix.text += "Geoidal height :" + String(lr_gh) mle_fix.text += "HDOP: " + String(lr_hdop) mle_fix.text += "Satellites: " + String(li_numsats) else return -1 end if else return -1 end if
The Latitude and Longitude properties of the GPSFix structure take a value of the GPSCoordinate structure. The following example shows how you might extend the previous example to display the Longitude property value in the multiline edit box. It takes the Minute property, separates it into whole minutes and a partial minute, and converts the partial minute into a number of seconds:
GPSCoordinate myLongCoord Integer fixLongMins, rc Real fixLongSecs ... rc = MyGPS.GetFix(myFix) myLongCoord = myFix.Longitude fixLongMins = Integer(myLongCoord.Minute) fixLongSecs = (myLongCoord.Minute - fixLongMins) * 60 mle_fix.text = "Longitude: " & + String(myLongCoord.degree) + " degrees " & + String(fixLongMins) + " minutes " & + String(fixLongSecs) + " seconds " & + String(myLongCoord.Hemisphere)