<filename>libgpsd_core.c</filename> Functions:-Direct access to GPSes on serial or USB devices. int gpsd_switch_driver(struct gps_device_t *session, char* typename) Test if the function is called with the same name as the active driver.If it is, test if the driver has a configurator function and is able to be reconfigured. A good result here will call the configurator and return a 0.For an entry with a different driver name, scan all available drivers to see if the wanted one is there. An unmatched name exits, returning 0.If we got a match, get the baudrate for the device with gpsd_assert_sync(), probe for the subtype if we have one.If the device has a configurator and is reconfigurable, trigger the configurator.Return a 1 to indicate a device switch. void gpsd_init(struct gps_device_t *session, struct gps_context_t *context, char *device) Copy the device name to the session data structure, initialise important data fields and call gpsd_tty_init(), gpsd_zero_satellites() and packet_reset(). void gpsd_deactivate(struct gps_device_t *session) All actions below, except the last one are conditional on the ntpd interface being compiled in.Release the ntpd resources, including the 1PPS resourecs if they are active.If the device has a revert function, trigger it.If it has an NMEA mode switcher, invoke it.If it has a wrapup routine, invoke it.Finally, close the device. static void *gpsd_ppsmonitor(void *arg) An ioctl() call is made which returns either 0 if the status of the port changed, or an error.If we got a change, we read the modem control bits and extract the 1PPS information.We check the returned value and see if it has changed recently. A counter of 10 unchanged events will disable further testing.If we are still hanging in there, we now see if we already have had more than 4 good fixes, otherwise we can't trust the 1PPS.We then finally test the pulse duration. If it is either a genuine 1PPS or a 2Hz squarewave, we call ntpshm_pps().Short or long PPS pulses are dropped with an error report. int gpsd_activate(struct gps_device_t *session, bool reconfigurable) Try and open the device, returning -1 if we fail.Probe all possible drivers to see if one recognises the device.Set some fundamental data to a clean value.Handle the initialisation of NTP and 1PPS functions if needed.If we did succeed in probing some device type, try and get the subtype.If we need to do so, we now configure the device.Finally, signal success by returning the file descriptor given by the device open call. char *gpsd_id(struct gps_device_t *session) If the device type is known, return it along with, where appropriate, the subtype. If the data is not available, return unknown. static double degtodm(double a) Converts a fractional degree value (like 125.3567) into an NMEA field as dddmm.xxx (like 12521.402). void gpsd_position_fix_dump(struct gps_device_t *session, /char bufp[], size_t len) If possible, create a $GPGGA message (full time, position and fix data) from the fix data, taking care about the validity of subsidiary fields like HDOP and altitude. static void gpsd_transit_fix_dump(struct gps_device_t *session, char bufp[], size_t len) Create a $GPRMC message (minimum navigation data) from the fix data. static void gpsd_binary_fix_dump(struct gps_device_t *session, char bufp[], size_t len) Make a call to gpsd_position_fix_dump() and gpsd_transit_fix_dump(). static void gpsd_binary_satellite_dump(struct gps_device_t *session, char bufp[], size_t len) Create one or more $GPGSV messages from the status data of all satellites we know about. static void gpsd_binary_quality_dump(struct gps_device_t *session, char bufp[], size_t len) Create a $GPGSA message taking care that if any xDOP is not valid, we substitute a 0.0 value.If any of the error estimates is available, generate a $PGRME message again taking care about possibly invalid values. static void gpsd_binary_dump(struct gps_device_t *session, char bufp[], size_t len) Dump such binary data as we have available; a fix, a quality value and a satellite status block. Each is enabled by the approriate status bits in the session mask variable. void gpsd_error_model(struct gps_device_t *session, struct gps_fix_t *fix, struct gps_fix_t *oldfix) Check we have a 2D fix (or better) and if the gps didn't provide an eph value, use the HDOP to calculate one or fail to NAN.Do the same with epv/VDOP if we have a 3D or better fix.Do the same with epe/PDOP.Consider speed error; check if we have two fixes with differing timestamps and use their times and eph values to calculate the speed.If we have two valid 3D fixes, we can calculate the climb/sink rate.Finally, just before exiting, save this fix as the old fix for the next comparison round. gps_mask_t gpsd_poll(struct gps_device_t *session) Make a call to gps_clear_fix() to prepare the data structure.Check if we know the device type. If we do, stash the count of of characters we are able to get from it.If the read has given a full packet, we can call the subtype probing method, if the device supports it.If we don't know the device type, try and figure out what it is, exiting if we can't.Make some checks if the device is offline or the packet is incomplete, using the stashed count of characters and the full packet indicator.If a full packet is available, we try to get the fix data and update the main data stucture. We also compute the DOPs so we can fill them in if they are not included in the gps device output.Finally, send the data to any clients who need raw mode data. void gpsd_wrap(struct gps_device_t *session) Simple call to gpsd_deactivate(session). void gpsd_zero_satellites(struct gps_data_t *out) Zero the status data for all satellites. Notes based on $Id: libgpsd_core.c 4284 2007-01-27 07:27:42Z ckuethe $