The GPS receiver is a Garmin 16 series unit. Schuyler Salz assembled an RJ45-to-serial adapter so that the data from the receiver could be read by a computer. The adapter also provides power to the receiver. Prior work on this unit was also done by Ben Vic.
A gpsd runs on the MCP's computer and is constantly receiving NMEA sentences from the gps unit. Any program running on the MCP can connect to the gpsd process through port 2497 retrieve data.
The MCP's navigation program uses libgps to connect to the gpsd. A thread in the navigation program continuously polls and receives data from gpsd. Information in the NMEA sentences are stored into gps_data_t struct. The latitude and longitude values are extracted from the struct and stored in global variables that are accessible to the rest of the GPS. The thread then takes the current position and the previous position of the MCP to determine the direction that the MCP is traveling in relation to the east.
Code listing 2.1: Class Declaration
#define D2R 57.29578 //180 degrees over pi radians
static double old_latitude;
static double old_longitude;
static double earth_radius = 6356.9; //in kilometers, the polar radius of the earth
static double smallest_lat=90;
static double smallest_lon=180;
static double largest_lat = -180;
static double largest_lon = -180;
// gps_data_t * gpsdata;
gps_data_t * getdata();
void update_gpsdata(char *message);
void *gps_monitor(void *arg);
double distance (double a1, double b1, double a2, double b2);
double lat2Y(double lat);
double lon2X(double lon);
double Y2lat(double Y);
double X2lon(double X);