# `drivers.c`

Functions:- | This is the main driver for NMEA, both plain vanilla and any manufacturer specific variety of NMEA output. This is NOT where manufacturer specific binary matters are handled.
--- | ---
Notes based on cde as of Mon Apr 5 21:38:06 2010 -0400.
`ssize_t generic_get(struct gps_device_t *session)` | This is a wrapper to call the real packet getter function, `packet_get()`.
`ssize_t pass_rtcm(struct gps_device_t *session, char *buf, size_t rtcmbytes)` | This writes the rtcm data to the device.

`gps_mask_t nmea_parse_input(struct gps_device_t *session)`

If the packet is a comment packet, ignore it and return 0.

If it is one of several binary packets, issue a warning to that effect.

If the relevant driver exists, switch to that driver and get it to parse the packet. The return value is that of the binary parser.

If the driver does not exist, ignore the packet and return 0.

If after all this, it is likely to be an NMEA packet, so try to parse it with the NMEA parser. If that returns a 0 (unsuccessful), then check if it is a trigger packet for one of the triggerable drivers.

If this succeeds, return 1, otherwise issue an unrecognised packet error.

Finally checks are made against openBSD's NMEA Line Discipline to make use of timestamping and if ntpd synchronising is active, the time is passed to the ntp daemon.

`static void nmea_probe_subtype(struct gps_device_t *session, unsigned int seq)` | This tries to probe for the NMEA mode of several popular chipsets. Most are detected by a trigger string.
| Several functions are omitted which are device specific. These are not covered here since they ARE device specific.
`static gps_mask_t rtcm104_analyze(struct gps_device_t *session)` | This function calls `rtcm_unpack()` to unpack rtcm packets into the session buffer.
| The last important thing in this code is an array of addresses, one for each compiled-in driver. This address gets us to the capabilities table in the bottom of each driver where we find what functions a driver supports and the entry address for each function.