Пример #1
0
static /*@observer@*/ char *report_hook(struct gps_device_t *session,
					struct timedrift_t *td)
/* ship the time of a PPS event to ntpd and/or chrony */
{
    char *log1;

    if (!session->ship_to_ntpd)
	return "skipped ship_to_ntp=0";

    /*
     * Only listen to PPS after several consecutive fixes,
     * otherwise time may be inaccurate.  (We know this is
     * required on some Garmins in binary mode; safest to do it
     * for all case we're talking to a Garmin in text mode, and
     * out of general safety-first conservatism.)
     *
     * Not sure yet how to handle u-blox UBX_MODE_TMONLY
     */
    if (session->fixcnt <= PPS_MIN_FIXES)
	return "no fix";

    log1 = "accepted";
    if ( 0 <= session->chronyfd ) {
	log1 = "accepted chrony sock";
	chrony_send(session, td);
    }
    (void)ntpshm_put(session, session->shmIndexPPS, td);

    return log1;
}
Пример #2
0
static char *report_hook(volatile struct pps_thread_t *pps_thread,
					struct timedelta_t *td)
/* ship the time of a PPS event to ntpd and/or chrony */
{
    char *log1;
    struct gps_device_t *session = (struct gps_device_t *)pps_thread->context;

    /* PPS only source never get any serial info
     * so no NTPTIME_IS or fixcnt */
    if ( source_pps != session->sourcetype) {
        /* FIXME! these two validations need to move back into ppsthread.c */

	if ( !session->ship_to_ntpd)
	    return "skipped ship_to_ntp=0";

	/*
	 * Only listen to PPS after several consecutive fixes,
	 * otherwise time may be inaccurate.  (We know this is
	 * required on all Garmin and u-blox; safest to do it
	 * for all cases as we have no other general way to know
	 * if PPS is good.
	 */
	if (session->fixcnt <= NTP_MIN_FIXES &&
	    (session->gpsdata.set & GOODTIME_IS) == 0)
	    return "no fix";
    }

    /* FIXME?  how to log socket AND shm reported? */
    log1 = "accepted";
    if ( 0 <= session->chronyfd ) {
	log1 = "accepted chrony sock";
	chrony_send(session, td);
    }
    if (session->shm_pps != NULL)
	(void)ntpshm_put(session, session->shm_pps, td);

    /* session context might have a hook set, too */
    if (session->context->pps_hook != NULL)
	session->context->pps_hook(session, td);

    return log1;
}