Graham Cantin / MODGPS

Dependents:   Telnet_server

Fork of MODGPS by Andy K

Embed: (wiki syntax)

« Back to documentation index

The MODGPS API

The MODGPS API

Functions

bool isTimeValid (void)
 Is the time reported by the GPS valid.
int getGPSquality (void)
 Is the positional fix reported by the GPS valid.
int numOfSats (void)
 How many satellites were used in the last fix.
double latitude (void)
 What was the last reported latitude (in degrees)
double longitude (void)
 What was the last reported longitude (in degrees)
double altitude (void)
 What was the last reported altitude (in kilometers)
double height (void)
 What was the last reported altitude/height (in kilometers)
GPS_Geodeticgeodetic (GPS_Geodetic *g)
 Get all three geodetic parameters together.
GPS_Geodeticgeodetic (void)
 Get all three geodetic parameters together.
GPS_TimetimeNow (GPS_Time *n)
 Take a snap shot of the current time.
GPS_TimetimeNow (void)
 Take a snap shot of the current time.
double julianDayNumber (void)
 Return the curent day.
double julianDate (void)
 Return the curent date/time as a Julian date.
double siderealDegrees (void)
 Get the current sidereal degree angle.
double siderealHA (void)
 Get the current sidereal hour angle.
void ppsAttach (PinName irq, ppsEdgeType type=ppsRise)
 Optionally, connect a 1PPS single to an Mbed pin.
template<typename T >
void attach_pps (T *tptr, void(T::*mptr)(void))
 Attach a user object/method callback function to the PPS signal.
void attach_pps (void(*fptr)(void))
 Attach a user callback function to the PPS signal.
template<typename T >
void attach_rmc (T *tptr, void(T::*mptr)(void))
 Attach a user callback function to the NMEA RMC message processed signal.
void attach_rmc (void(*fptr)(void))
 Attach a user callback function to the NMEA RMC message processed signal.
template<typename T >
void attach_gga (T *tptr, void(T::*mptr)(void))
 Attach a user callback function to the NMEA GGA message processed signal.
void attach_gga (void(*fptr)(void))
 Attach a user callback function to the NMEA GGA message processed signal.
void baud (int baudrate)
 Set the baud rate the GPS module is using.
void format (int bits, Parity parity, int stop_bits)
 Set the serial port format the GPS module is using.

Function Documentation

double altitude ( void   ) [inherited]

What was the last reported altitude (in kilometers)

Method returns a double in kilometers.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     double altitude = gps.altitude();
Returns:
double Kilometers

Definition at line 77 of file GPS.cpp.

void attach_gga ( T *  tptr,
void(T::*)(void)  mptr 
) [inherited]

Attach a user callback function to the NMEA GGA message processed signal.

Attach a user callback object/method to call when an NMEA GGA packet has been processed.

     class FOO {
     public:
         void myCallback(void);
     };

     GPS gps(NC, p9); 
     Foo foo;

     gps.attach_gga(foo, &FOO::myCallback);
Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called

Definition at line 580 of file GPS.h.

void attach_gga ( void(*)(void)  fptr ) [inherited]

Attach a user callback function to the NMEA GGA message processed signal.

Attach a user callback function pointer to call when an NMEA GGA packet has been processed.

     void myCallback(void) { ... }

     GPS gps(NC, p9); 
     Foo foo;

     gps.attach_gga(&myCallback);
Parameters:
fptrCallback function pointer.

Definition at line 599 of file GPS.h.

void attach_pps ( void(*)(void)  fptr ) [inherited]

Attach a user callback function to the PPS signal.

Attach a user callback function pointer to call when the 1PPS signal activates.

     void myCallback(void) { ... }

     GPS gps(NC, p9); 
     Foo foo;

     gps.attach_pps(&myCallback);
Parameters:
fptrCallback function pointer

Definition at line 507 of file GPS.h.

void attach_pps ( T *  tptr,
void(T::*)(void)  mptr 
) [inherited]

Attach a user object/method callback function to the PPS signal.

Attach a user callback object/method to call when the 1PPS signal activates.

     class FOO {
     public:
         void myCallback(void);
     };

     GPS gps(NC, p9); 
     Foo foo;

     gps.attach_pps(foo, &FOO::myCallback);
Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called

Definition at line 488 of file GPS.h.

void attach_rmc ( T *  tptr,
void(T::*)(void)  mptr 
) [inherited]

Attach a user callback function to the NMEA RMC message processed signal.

Attach a user callback object/method to call when an NMEA RMC packet has been processed.

     class FOO {
     public:
         void myCallback(void);
     };

     GPS gps(NC, p9); 
     Foo foo;

     gps.attach_rmc(foo, &FOO::myCallback);
Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called

Definition at line 534 of file GPS.h.

void attach_rmc ( void(*)(void)  fptr ) [inherited]

Attach a user callback function to the NMEA RMC message processed signal.

Attach a user callback function pointer to call when an NMEA RMC packet has been processed.

     void myCallback(void) { ... }

     GPS gps(NC, p9); 
     Foo foo;

     gps.attach_rmc(&myCallback);
Parameters:
fptrCallback function pointer.

Definition at line 553 of file GPS.h.

void baud ( int  baudrate ) [inherited]

Set the baud rate the GPS module is using.

Set the baud rate of the serial port

See also:
http://mbed.org/projects/libraries/api/mbed/trunk/Serial#Serial.baud
Parameters:
baudrateThe baudrate to set.

Definition at line 613 of file GPS.h.

void format ( int  bits,
Parity  parity,
int  stop_bits 
) [inherited]

Set the serial port format the GPS module is using.

Set the transmission format used by the Serial port

See also:
http://mbed.org/projects/libraries/api/mbed/trunk/Serial#Serial.format
Parameters:
bits- The number of bits in a word (5-8; default = 8)
parity- The parity used (GPS::None, GPS::Odd, GPS::Even, GPS::Forced1, GPS::Forced0; default = GPS::None)
stop_bits- The number of stop bits (1 or 2; default = 1)

Definition at line 626 of file GPS.h.

GPS_Geodetic* geodetic ( void   ) [inherited]

Get all three geodetic parameters together.

Get all the geodetic data at once. For example:-

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     // Then get the data...
     GPS_Geodetic *p = gps.geodetic();
     printf("Latitude = %.4f", p->lat);
     delete(p); // then remember to delete the object to prevent memory leaks.
Returns:
GPS_Geodetic * A pointer to the data.

Definition at line 303 of file GPS.h.

GPS_Geodetic * geodetic ( GPS_Geodetic g ) [inherited]

Get all three geodetic parameters together.

Pass a pointer to a GPS_Geodetic object and the current GPS data will be copied into it.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     // Then get the data...
     GPS_Geodetic p;
     gps.geodetic(&p);
     printf("Latitude  = %.4f", p.lat);
     printf("Longitude = %.4f", p.lon);
     printf("Altitude  = %.4f", p.alt);
Parameters:
gA GSP_Geodetic pointer to an existing GPS_Geodetic object.
Returns:
GPS_Geodetic * The pointer passed in.

Definition at line 85 of file GPS.cpp.

int getGPSquality ( void   ) [inherited]

Is the positional fix reported by the GPS valid.

Method used to check the validity of the positional data. This method returns the GGA field, 0 is "bad, 1 is "ok", etc. See the NMEA GGA description for more details.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     if (gps.getGPSquality() == 0) {
         // The location fix is no good/not accurate :(
     }
     else {
         // All good, can use last fix data.
     )
Returns:
int 0 on no fix, 1... (see NMEA GGA for more details).

Definition at line 171 of file GPS.h.

double height ( void   ) [inherited]

What was the last reported altitude/height (in kilometers)

See also:
altitude()
     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     double height = gps.height();

Note, this is identical to altitude()

See also:
altitude()
Returns:
double Kilometers

Definition at line 259 of file GPS.h.

bool isTimeValid ( void   ) [inherited]

Is the time reported by the GPS valid.

Method used to check the validity of the time the GPS module is reporting.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     if (gps.isTimeValid()) {
         // Time is valid :)
     }
     else {
         // Doh, time is not valid :(
     )
Returns:
bool true if valid, false otherwise

Definition at line 147 of file GPS.h.

double julianDate ( void   ) [inherited]

Return the curent date/time as a Julian date.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     // Then get the Julian Date.
     double julianDate = gps.julianDate();
Returns:
double The Julian Date as a double.

Definition at line 378 of file GPS.h.

double julianDayNumber ( void   ) [inherited]

Return the curent day.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     // Then get the Julain Day Number.
     double julianDayNumber = gps.julianDayNumber();
Returns:
double The Julian Date as a double.

Definition at line 362 of file GPS.h.

double latitude ( void   ) [inherited]

What was the last reported latitude (in degrees)

Method returns a double in degrees, positive being North, negative being South.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     double latitude = gps.latitude();
Returns:
double Degrees

Definition at line 61 of file GPS.cpp.

double longitude ( void   ) [inherited]

What was the last reported longitude (in degrees)

Method returns a double in degrees, positive being East, negative being West.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     double logitude = gps.logitude();
Returns:
double Degrees

Definition at line 69 of file GPS.cpp.

int numOfSats ( void   ) [inherited]

How many satellites were used in the last fix.

Method returns the number of GPS satellites used on the last fix.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     int sats = gps.numOfSats();
Returns:
int The number of satellites.

Definition at line 188 of file GPS.h.

void ppsAttach ( PinName  irq,
ppsEdgeType  type = ppsRise 
) [inherited]

Optionally, connect a 1PPS single to an Mbed pin.

Optional: If the GPS unit has a 1PPS output, use this to connect that to our internal ISR. Using the 1PPS increases the GPS_Time time accuracy from +/-0.25s to +/-0.001s

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     gps.ppsAttach(p29); // default to GPS::ppsRise, rising edge. 

     // Or...
     gps.ppsAttach(p29, GPS::ppsRise ); // The default.

     // Or...
     gps.ppsAttach(p29, GPS::ppsFall ); // If a falling edge.

Note, before using this function you should attach an actual callback function using attach_pps()

See also:
attach_pps()
Parameters:
irqA PinName to attach
typeThe type of edge, MAX7456::ppsRise OR MAX7456::ppsFall

Definition at line 44 of file GPS.cpp.

double siderealDegrees ( void   ) [inherited]

Get the current sidereal degree angle.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 
     double sidereal = gps.siderealDegrees();
Returns:
double Sidereal degree angle..

Definition at line 392 of file GPS.h.

double siderealHA ( void   ) [inherited]

Get the current sidereal hour angle.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 
     double sidereal = gps.siderealHA();
Returns:
double Sidereal degree angle..

Definition at line 406 of file GPS.h.

GPS_Time* timeNow ( void   ) [inherited]

Take a snap shot of the current time.

Pass a pointer to a GPS_Time object to get a copy of the current time and date as reported by the GPS.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     // Then get the data...
     GPS_Time *t = gps.timeNow();
     printf("Year = %d", t->year);
     delete(t); // Avoid memory leaks.
Returns:
GPS_Time * The pointer passed in.

Definition at line 346 of file GPS.h.

GPS_Time* timeNow ( GPS_Time n ) [inherited]

Take a snap shot of the current time.

Pass a pointer to a GPS_Time object to get a copy of the current time and date as reported by the GPS.

     // Assuming we have a GPS object previously created...
     GPS gps(NC, p9); 

     // Then get the data...
     GPS_Time t;
     gps.timeNow(&t);
     printf("Year = %d", t.year);
Parameters:
nA GPS_Time * pointer to an existing GPS_Time object.
Returns:
GPS_Time * The pointer passed in.

Definition at line 325 of file GPS.h.