# isgps.c

Functions:- | This contains low level handling for the data transmission format of the satellite downlink and the RTCM2 radio data stream. ESR comments You are not expected to understand any of this.. Let's try anyhow.
Notes based on code as of Mon Apr 5 21:38:06 2010 -0400.
`static unsigned char parity_array[]` | An array of parity values to allow fast lookup instead of calculation.
`static unsigned int reverse_bits[]` | An array of conversion values to allow fast lookup instead of calculation.
`unsigned int isgps_parity(isgps30bits_t th)` | Calculate the ISGPS parity for the incoming 30 bit word. This involves lots of masking (with preset values or values searched through `parity_array[]`) and shifting
`void isgps_init(struct gps_packet_t *session)` | Initialise the ISGPS data for the current session.
`enum isgpsstat_t isgps_decode(struct gps_packet_t *session, bool (*preamble_match)(isgps30bits_t *), bool (*length_check)(struct gps_packet_t *), size_t maxlen, unsigned int c)` | Check the validity of the ISGPS word tag (incoming data `unsigned int c`) and exit with an error if it is not valid. If the session has not already locked with the datastream, loop through the data and try and sync up. If sync is achieved, exit early with an indication of sync, or fall through still marked unsynced. If the session is already locked to the datastream, read the data into the session buffer. All the while, take care that the datastream is not corrupted. Any error will result in an early return with an appropriate error code. At the end of this section, return the status of the operations. Finally, if the above two sections failed, exit with an error indicating that lock was not achieved.
`void isgps_output_magnavox(isgps30bits_t *ip, unsigned int len, FILE *fp)` | Ship an IS-GPS-200 message to standard output in Magnavox format.