FreeBSD/contrib/ntp/ntpd/refclock_mx4200.c
/*
 * Process a PPS signal, placing a timestamp in pp->lastrec.
 */
Process a PPS signal, placing a timestamp in pp->lastrec.
Process a PPS signal placing a timestamp in pp - > lastrec .
static int
mx4200_pps(
	struct peer *peer
	)
{
	int temp_serial;
	struct refclockproc *pp;
	struct mx4200unit *up;
	struct timespec timeout;
	pp = peer->procptr;
	up = pp->unitptr;
	temp_serial = up->pps_i.assert_sequence;
	timeout.tv_sec  = 0;
	timeout.tv_nsec = 0;
	if (time_pps_fetch(up->pps_h, PPS_TSFMT_TSPEC, &(up->pps_i),
			&timeout) < 0) {
		mx4200_debug(peer,
		  "mx4200_pps: time_pps_fetch: serial=%lu, %m\n",
		     (unsigned long)up->pps_i.assert_sequence);
		refclock_report(peer, CEVNT_FAULT);
		return(1);
	}
	if (temp_serial == up->pps_i.assert_sequence) {
		mx4200_debug(peer,
		   "mx4200_pps: assert_sequence serial not incrementing: %lu\n",
			(unsigned long)up->pps_i.assert_sequence);
		refclock_report(peer, CEVNT_FAULT);
		return(1);
	}
	if (up->lastserial + 1 != up->pps_i.assert_sequence &&
	    up->lastserial != 0) {
		if (up->pps_i.assert_sequence == up->lastserial) {
			mx4200_debug(peer, "mx4200_pps: no new pps event\n");
		} else {
			mx4200_debug(peer, "mx4200_pps: missed %lu pps events\n",
			    up->pps_i.assert_sequence - up->lastserial - 1UL);
		}
		refclock_report(peer, CEVNT_FAULT);
	}
	up->lastserial = up->pps_i.assert_sequence;
	pp->lastrec.l_ui = up->pps_i.assert_timestamp.tv_sec +
			   (u_int32) JAN_1970;
	pp->lastrec.l_uf = ((double)(up->pps_i.assert_timestamp.tv_nsec) *
			   4.2949672960) + 0.5;
	return(0);
}
static int mx4200_pps ( struct peer * peer ) { int temp_serial ; struct refclockproc * pp ; struct mx4200unit * up ; struct timespec timeout ; pp = peer -> procptr ; up = pp -> unitptr ; temp_serial = up -> pps_i . assert_sequence ; timeout . tv_sec = 0 ; timeout . tv_nsec = 0 ; if ( time_pps_fetch ( up -> pps_h , PPS_TSFMT_TSPEC , & ( up -> pps_i ) , & timeout ) < 0 ) { mx4200_debug ( peer , " \n " , ( unsigned long ) up -> pps_i . assert_sequence ) ; refclock_report ( peer , CEVNT_FAULT ) ; return ( 1 ) ; } if ( temp_serial == up -> pps_i . assert_sequence ) { mx4200_debug ( peer , " \n " , ( unsigned long ) up -> pps_i . assert_sequence ) ; refclock_report ( peer , CEVNT_FAULT ) ; return ( 1 ) ; } if ( up -> lastserial + 1 != up -> pps_i . assert_sequence && up -> lastserial != 0 ) { if ( up -> pps_i . assert_sequence == up -> lastserial ) { mx4200_debug ( peer , " \n " ) ; } else { mx4200_debug ( peer , " \n " , up -> pps_i . assert_sequence - up -> lastserial - 1UL ) ; } refclock_report ( peer , CEVNT_FAULT ) ; } up -> lastserial = up -> pps_i . assert_sequence ; pp -> lastrec . l_ui = up -> pps_i . assert_timestamp . tv_sec + ( u_int32 ) JAN_1970 ; pp -> lastrec . l_uf = ( ( double ) ( up -> pps_i . assert_timestamp . tv_nsec ) * 4.2949672960 ) + 0.5 ; return ( 0 ) ; }
Process a PPS signal, placing a timestamp in pp->lastrec.
Process a PPS signal placing a timestamp in pp - > lastrec .
/*
	 * Grab the timestamp of the PPS signal.
	 */ /*
	 * Check pps serial number against last one
	 */ /*
	 * Return the timestamp in pp->lastrec
	 */