GetFix

Description

Populates a GPSFix structure with data from the current position fix.

Applies to

GPS and SerialGPS objects

Syntax

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

Returns

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:

Usage

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.

Examples

Example 1

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

Example 2

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)

See also