Example #1
0
/*
 * shm_clockstats - dump and reset counters
 */
static void shm_clockstats(
	int unit,
	struct peer *peer
	)
{
	struct refclockproc * const pp = peer->procptr;
	struct shmunit *      const up = pp->unitptr;

	UNUSED_ARG(unit);
	if (pp->sloppyclockflag & CLK_FLAG4) {
		mprintf_clock_stats(
			&peer->srcadr, "%3d %3d %3d %3d %3d",
			up->ticks, up->good, up->notready,
			up->bad, up->clash);
	}
	up->ticks = up->good = up->notready = up->bad = up->clash = 0;
}
Example #2
0
/*
 * atom_timer - called once per second
 */
void
atom_timer(
	int	unit,		/* unit pointer (not used) */
	struct peer *peer	/* peer structure pointer */
	)
{
	struct	ppsunit *up;
	struct	refclockproc *pp;
	pps_status rc;

	UNUSED_ARG(unit);

	pp = peer->procptr;
	up = pp->unitptr;
	rc = refclock_pps(peer, &up->atom, pp->sloppyclockflag);
        switch (rc) {
            case PPS_OK:
                up->pcount++;
                break;
            default:
            case PPS_SETUP:
                up->scount++;
                break;
            case PPS_KERNEL:
                up->kcount++;
                break;
            case PPS_NREADY:
                up->rcount++;
                break;
        }
        if (rc != PPS_OK) return;

	peer->flags |= FLAG_PPS;

	/*
	 * If flag4 is lit, record each second offset to clockstats.
	 * That's so we can make awesome Allan deviation plots.
	 */
	if (pp->sloppyclockflag & CLK_FLAG4) {
		mprintf_clock_stats(&peer->srcadr, "%.9f",
			pp->filter[pp->coderecv]);
	}
}
Example #3
0
/*
 * atom_poll - called by the transmit procedure
 */
static void
atom_poll(
	int unit,		/* unit number (not used) */
	struct peer *peer	/* peer structure pointer */
	)
{
	struct ppsunit *up;
	struct refclockproc *pp;

	UNUSED_ARG(unit);

	pp = peer->procptr;
	up = (struct ppsunit *)pp->unitptr;

	/*
	 * Don't wiggle the clock until some other driver has numbered
	 * the seconds.
	 */
	if (sys_leap == LEAP_NOTINSYNC) {
		pp->codeproc = pp->coderecv;  // xxx ??
		up->pcount = up->scount = up->kcount = up->rcount = 0;
		return;
        }

	pp->polls++;

	mprintf_clock_stats(&peer->srcadr,
	    "%ld %d %d %d %d",
	    up->atom.sequence,
	    up->pcount, up->scount, up->kcount, up->rcount);
	up->pcount = up->scount = up->kcount = up->rcount = 0;

	if (pp->codeproc == pp->coderecv) {
		peer->flags &= ~FLAG_PPS;
		refclock_report(peer, CEVNT_TIMEOUT);
		return;
	}
	pp->lastref = pp->lastrec;
	refclock_receive(peer);
}