ntpshmwrite.c
Functions:-This puts time information into a shared memory segment for the ntp daemon to use.
Notes based on code as of Tue Apr 6 10:17:55 2010 -0400.
static struct shmTime *getShmTime(int unit)
This requests a block of shared memory to communicate
to the ntp daemon. It returns a pointer to the memory on success or
NULL on failure.
void ntpshm_init(struct gps_context_t *context, bool enablepps)
Attaches all ntp shared memory segments, flagging the
availability of the NMEA and 1pps capabilities as
appropriate.
int ntpshm_alloc(struct gps_context_t *context)
This tries to allocate a free ntp shared memory
segment.If one is available, initialise it for use and
flag it as in use.Returns the segment number on success
or -1 on failure.
bool ntpshm_free(struct gps_context_t *context, int segment)
This tries to release a previously allocated ntp shared
memory segment. Indicates the outcome by returning true (success) or
false.
int ntpshm_put(struct gps_device_t *session, double fixtime)
If the shared memory index allocated to the session is
valid and the shmTime structure of the session
is valid, store the time of the fix.Success is
indicated by a return value of 1 and errors are indicated by a
return value of 0.
int ntpshm_pps(struct gps_device_t *session, struct timeval *tv)
This code is only available if the 1PPS function is
compiled in.The shared memory structures are checked
for validity and if not valid, a 0 is returned.The time
received is then checked to be within 100 milliseconds of the PC's
internal time and if not, a -1 is
returned.The time received is then checked
to be within 500 milliseconds of the second boundary and if not, the
shared memory structure is advised that lock is lost and a -1 is
returned.If good, the time is stored in the shared
memory and 1 is returned.