Lines Matching +full:negative +full:- +full:phase
2 * ntp_refclock - processing support for reference clocks
53 * In addition, there may be a driver-specific unit structure used for
57 * which is used for all peer-specific processing and contains a
82 #if MAXSTAGE & (MAXSTAGE - 1)
89 pp->coderecv = (pp->coderecv + 1) % MAXSTAGE; in clk_add_sample()
90 if (pp->coderecv == pp->codeproc) in clk_add_sample()
91 pp->codeproc = (pp->codeproc + 1) % MAXSTAGE; in clk_add_sample()
92 pp->filter[pp->coderecv] = sv; in clk_add_sample()
99 if (pp->coderecv == pp->codeproc) in clk_pop_sample()
101 pp->codeproc = (pp->codeproc + 1) % MAXSTAGE; in clk_pop_sample()
102 return pp->filter[pp->codeproc]; in clk_pop_sample()
109 u_int retv = pp->coderecv - pp->codeproc; in clk_cnt_sample()
122 pp->coderecv = (pp->coderecv + 1) & (MAXSTAGE - 1); in clk_add_sample()
123 if (pp->coderecv == pp->codeproc) in clk_add_sample()
124 pp->codeproc = (pp->codeproc + 1) & (MAXSTAGE - 1); in clk_add_sample()
125 pp->filter[pp->coderecv] = sv; in clk_add_sample()
132 if (pp->coderecv == pp->codeproc) in clk_pop_sample()
134 pp->codeproc = (pp->codeproc + 1) & (MAXSTAGE - 1); in clk_pop_sample()
135 return pp->filter[pp->codeproc]; in clk_pop_sample()
142 return (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1); in clk_cnt_sample()
148 * refclock_report - note the occurance of an event
162 pp = peer->procptr; in refclock_report()
169 pp->noreply++; in refclock_report()
173 pp->badformat++; in refclock_report()
181 pp->baddata++; in refclock_report()
188 if ((code != CEVNT_NOMINAL) && (pp->lastevent < 15)) in refclock_report()
189 pp->lastevent++; in refclock_report()
190 if (pp->currentstatus != code) { in refclock_report()
191 pp->currentstatus = (u_char)code; in refclock_report()
198 * init_refclock - initialize the reference clock drivers
210 if (refclock_conf[i]->clock_init != noentry) in init_refclock()
211 (refclock_conf[i]->clock_init)(); in init_refclock()
216 * refclock_newpeer - initialize and start a reference clock
220 * driver-specific support routine completes the initialization, if
240 if (!ISREFCLOCKADR(&peer->srcadr)) { in refclock_newpeer()
243 stoa(&peer->srcadr)); in refclock_newpeer()
246 clktype = (u_char)REFCLOCKTYPE(&peer->srcadr); in refclock_newpeer()
247 unit = REFCLOCKUNIT(&peer->srcadr); in refclock_newpeer()
249 refclock_conf[clktype]->clock_start == noentry) { in refclock_newpeer()
260 peer->procptr = pp; in refclock_newpeer()
265 peer->refclktype = clktype; in refclock_newpeer()
266 peer->refclkunit = (u_char)unit; in refclock_newpeer()
267 peer->flags |= FLAG_REFCLOCK; in refclock_newpeer()
268 peer->leap = LEAP_NOTINSYNC; in refclock_newpeer()
269 peer->stratum = STRATUM_REFCLOCK; in refclock_newpeer()
270 peer->ppoll = peer->maxpoll; in refclock_newpeer()
271 pp->type = clktype; in refclock_newpeer()
272 pp->conf = refclock_conf[clktype]; in refclock_newpeer()
273 pp->timestarted = current_time; in refclock_newpeer()
274 pp->io.fd = -1; in refclock_newpeer()
279 switch (peer->hmode) { in refclock_newpeer()
281 peer->pmode = MODE_PASSIVE; in refclock_newpeer()
285 peer->pmode = MODE_SERVER; in refclock_newpeer()
293 if (!((refclock_conf[clktype]->clock_start)(unit, peer))) { in refclock_newpeer()
297 peer->refid = pp->refid; in refclock_newpeer()
303 * refclock_unpeer - shut down a clock
317 if (NULL == peer->procptr) in refclock_unpeer()
320 clktype = peer->refclktype; in refclock_unpeer()
321 unit = peer->refclkunit; in refclock_unpeer()
322 if (refclock_conf[clktype]->clock_shutdown != noentry) in refclock_unpeer()
323 (refclock_conf[clktype]->clock_shutdown)(unit, peer); in refclock_unpeer()
324 free(peer->procptr); in refclock_unpeer()
325 peer->procptr = NULL; in refclock_unpeer()
330 * refclock_timer - called once per second for housekeeping.
340 unit = p->refclkunit; in refclock_timer()
341 pp = p->procptr; in refclock_timer()
342 if (pp->conf->clock_timer != noentry) in refclock_timer()
343 (*pp->conf->clock_timer)(unit, p); in refclock_timer()
344 if (pp->action != NULL && pp->nextaction <= current_time) in refclock_timer()
345 (*pp->action)(p); in refclock_timer()
350 * refclock_transmit - simulate the transmit procedure
365 clktype = peer->refclktype; in refclock_transmit()
366 unit = peer->refclkunit; in refclock_transmit()
367 peer->sent++; in refclock_transmit()
368 get_systime(&peer->xmt); in refclock_transmit()
373 * protocol here and call the driver-specific transmit routine. in refclock_transmit()
375 if (peer->burst == 0) { in refclock_transmit()
380 current_time, stoa(&(peer->srcadr))); in refclock_transmit()
387 oreach = peer->reach & 0xfe; in refclock_transmit()
388 peer->reach <<= 1; in refclock_transmit()
389 if (!(peer->reach & 0x0f)) in refclock_transmit()
391 peer->outdate = current_time; in refclock_transmit()
392 if (!peer->reach) { in refclock_transmit()
395 peer->timereachable = current_time; in refclock_transmit()
398 if (peer->flags & FLAG_BURST) in refclock_transmit()
399 peer->burst = NSTAGE; in refclock_transmit()
402 peer->burst--; in refclock_transmit()
404 peer->procptr->inpoll = TRUE; in refclock_transmit()
405 if (refclock_conf[clktype]->clock_poll != noentry) in refclock_transmit()
406 (refclock_conf[clktype]->clock_poll)(unit, peer); in refclock_transmit()
407 poll_update(peer, peer->hpoll, 0); in refclock_transmit()
412 * Compare two doubles - used with qsort()
424 return -1; in refclock_cmpl_fp()
440 # if MAXSTAGE & (MAXSTAGE - 1) in refclock_samples_avail()
442 na = pp->coderecv - pp->codeproc; in refclock_samples_avail()
448 na = (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1); in refclock_samples_avail()
470 # if MAXSTAGE & (MAXSTAGE - 1) in refclock_samples_expire()
472 na = pp->coderecv - pp->codeproc; in refclock_samples_expire()
477 pp->codeproc = (pp->codeproc + nd) % MAXSTAGE; in refclock_samples_expire()
481 na = (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1); in refclock_samples_expire()
484 pp->codeproc = (pp->codeproc + nd) & (MAXSTAGE - 1); in refclock_samples_expire()
491 * refclock_process_offset - update median filter
508 pp->lastrec = lastrec; in refclock_process_offset()
513 refclock_checkburst(pp->io.srcclock, pp); in refclock_process_offset()
518 * refclock_process - process a sample from the clock
519 * refclock_process_f - refclock_process with other than time1 fudge
527 * Important for PPS users: Normally, the pp->lastrec is set to the
528 * system time when the on-time character is received and the pp->year,
529 * ..., pp->second decoded and the seconds fraction pp->nsec in
530 * nanoseconds). When a PPS offset is available, pp->nsec is forced to
531 * zero and the fraction for pp->lastrec is set to the PPS offset.
549 if (!clocktime(pp->day, pp->hour, pp->minute, pp->second, GMT, in refclock_process_f()
550 pp->lastrec.l_ui, &pp->yearstart, &offset.l_ui)) in refclock_process_f()
554 DTOLFP(pp->nsec / 1e9, <emp); in refclock_process_f()
556 refclock_process_offset(pp, offset, pp->lastrec, fudge); in refclock_process_f()
566 return refclock_process_f(pp, pp->fudgetime1); in refclock_process()
571 * refclock_sample - process a pile of samples from the clock
593 while (pp->codeproc != pp->coderecv) in refclock_sample()
610 m = n - (n * 4) / 10; in refclock_sample()
611 while ((k = j - i) > m) { in refclock_sample()
612 k = (k - 1) >> 1; in refclock_sample()
613 if ((off[j - 1] - off[j - k - 1]) < (off[i + k] - off[i])) in refclock_sample()
616 j--; /* reject high end */ in refclock_sample()
622 pp->offset = off[i]; in refclock_sample()
623 pp->jitter = 0; in refclock_sample()
625 pp->offset += off[k]; in refclock_sample()
626 pp->jitter += SQUARE(off[k] - off[k - 1]); in refclock_sample()
628 pp->offset /= m; in refclock_sample()
629 m -= (m > 1); /* only (m-1) terms attribute to jitter! */ in refclock_sample()
630 pp->jitter = max(SQRT(pp->jitter / m), LOGTOD(sys_precision)); in refclock_sample()
643 pp->jitter = max(pp->jitter, pp->fudgeminjitter); in refclock_sample()
649 (int)n, pp->offset, pp->disp, pp->jitter); in refclock_sample()
656 * refclock_receive - simulate the receive and packet procedures
674 current_time, stoa(&peer->srcadr)); in refclock_receive()
682 pp = peer->procptr; in refclock_receive()
683 pp->inpoll = FALSE; in refclock_receive()
684 peer->leap = pp->leap; in refclock_receive()
685 if (peer->leap == LEAP_NOTINSYNC) in refclock_receive()
688 peer->received++; in refclock_receive()
689 peer->timereceived = current_time; in refclock_receive()
690 if (!peer->reach) { in refclock_receive()
692 peer->timereachable = current_time; in refclock_receive()
694 peer->reach = (peer->reach << (peer->reach & 1)) | 1; in refclock_receive()
695 peer->reftime = pp->lastref; in refclock_receive()
696 peer->aorg = pp->lastrec; in refclock_receive()
697 peer->rootdisp = pp->disp; in refclock_receive()
698 get_systime(&peer->dst); in refclock_receive()
702 clock_filter(peer, pp->offset, 0., pp->jitter); in refclock_receive()
705 if (sys_peer->refclktype == REFCLK_ATOM_PPS && in refclock_receive()
706 peer->refclktype != REFCLK_ATOM_PPS) in refclock_receive()
707 pp->fudgetime1 -= pp->offset * FUDGEFAC; in refclock_receive()
713 * refclock_gtlin - groom next input line and extract timestamp
737 dpend = dp + bmax - 1; /* leave room for NUL pad */ in refclock_gtlin()
738 sp = (const char *)rbufp->recv_buffer; in refclock_gtlin()
739 spend = sp + rbufp->recv_length; in refclock_gtlin()
752 dlen = dp - lineptr; in refclock_gtlin()
755 *tsptr = rbufp->recv_time; in refclock_gtlin()
757 rbufp->fd, ulfptoa(&rbufp->recv_time, 6), dlen, in refclock_gtlin()
766 * refclock_gtraw - get next line/chunk of data
790 bmax -= 1; /* leave room for trailing NUL */ in refclock_gtraw()
791 if (bmax > rbufp->recv_length) in refclock_gtraw()
792 bmax = rbufp->recv_length; in refclock_gtraw()
793 memcpy(lineptr, rbufp->recv_buffer, bmax); in refclock_gtraw()
796 *tsptr = rbufp->recv_time; in refclock_gtraw()
798 rbufp->fd, ulfptoa(&rbufp->recv_time, 6), bmax, in refclock_gtraw()
836 refnumtoa(&peer->srcadr), what, in refclock_fdwrite()
843 refnumtoa(&peer->srcadr), what, in refclock_fdwrite()
859 if ( ! (peer && peer->procptr)) { in refclock_write()
863 refnumtoa(&peer->srcadr), what); in refclock_write()
867 return refclock_fdwrite(peer, peer->procptr->io.fd, in refclock_write()
889 if (rio->io_input != NULL && (*rio->io_input)(rb) == 0) { in indicate_refclock_packet()
891 * data was consumed - nothing to pass up in indicate_refclock_packet()
920 rio = &rb->recv_peer->procptr->io; in process_refclock_packet()
926 if (rio->io_input == NULL || (*rio->io_input)(rb) != 0) { in process_refclock_packet()
927 rio->recvcount++; in process_refclock_packet()
930 (*rio->clock_recv)(rb); in process_refclock_packet()
943 * refclock_open - open serial port for reference clock
947 * returns -1.
990 return -1; in refclock_open()
994 return -1; in refclock_open()
998 return -1; in refclock_open()
1006 * buffer. Since we have non-blocking IO available, this is a in refclock_open()
1018 * refclock_setup - initialize terminal interface structure
1032 * (line-oriented) mode at specified line speed, 8 bits and no in refclock_setup()
1060 ttyp->c_iflag = IGNBRK | IGNPAR | ICRNL; in refclock_setup()
1061 ttyp->c_oflag = 0; in refclock_setup()
1062 ttyp->c_cflag = CS8 | CLOCAL | CREAD; in refclock_setup()
1064 /* HP Z3801A needs 7-bit, odd parity */ in refclock_setup()
1065 ttyp->c_cflag = CS7 | PARENB | PARODD | CLOCAL | CREAD; in refclock_setup()
1070 ttyp->c_cc[i] = '\0'; in refclock_setup()
1088 ttyp->c_cflag &= ~CLOCAL; in refclock_setup()
1093 * Set raw and echo modes. These can be changed on-fly. in refclock_setup()
1095 ttyp->c_lflag = ICANON; in refclock_setup()
1097 ttyp->c_lflag = 0; in refclock_setup()
1098 ttyp->c_iflag = 0; in refclock_setup()
1099 ttyp->c_cc[VMIN] = 1; in refclock_setup()
1102 ttyp->c_lflag |= ECHO; in refclock_setup()
1144 ttyp->c_iflag = IGNBRK | IGNPAR | ICRNL; in refclock_setup()
1145 ttyp->c_oflag = 0; in refclock_setup()
1146 ttyp->c_cflag = speed | CS8 | CLOCAL | CREAD; in refclock_setup()
1148 ttyp->c_cc[i] = '\0'; in refclock_setup()
1166 ttyp->c_cflag &= ~CLOCAL; in refclock_setup()
1171 * Set raw and echo modes. These can be changed on-fly. in refclock_setup()
1173 ttyp->c_lflag = ICANON; in refclock_setup()
1175 ttyp->c_lflag = 0; in refclock_setup()
1176 ttyp->c_iflag = 0; in refclock_setup()
1177 ttyp->c_cc[VMIN] = 1; in refclock_setup()
1202 ttyp->sg_ispeed = ttyp->sg_ospeed = speed; in refclock_setup()
1203 ttyp->sg_flags = EVENP | ODDP | CRMOD; in refclock_setup()
1217 * refclock_ioctl - set serial port control functions
1219 * This routine attempts to hide the internal, system-specific details
1242 * refclock_control - set and/or return clock values
1271 peer = findexistingpeer(srcadr, NULL, NULL, -1, 0, NULL); in refclock_control()
1276 INSIST(peer->procptr != NULL); in refclock_control()
1277 pp = peer->procptr; in refclock_control()
1283 if (in->haveflags & CLK_HAVETIME1) in refclock_control()
1284 pp->fudgetime1 = in->fudgetime1; in refclock_control()
1285 if (in->haveflags & CLK_HAVETIME2) in refclock_control()
1286 pp->fudgetime2 = in->fudgetime2; in refclock_control()
1287 if (in->haveflags & CLK_HAVEVAL1) in refclock_control()
1288 peer->stratum = pp->stratum = (u_char)in->fudgeval1; in refclock_control()
1289 if (in->haveflags & CLK_HAVEVAL2) in refclock_control()
1290 peer->refid = pp->refid = in->fudgeval2; in refclock_control()
1291 if (in->haveflags & CLK_HAVEFLAG1) { in refclock_control()
1292 pp->sloppyclockflag &= ~CLK_FLAG1; in refclock_control()
1293 pp->sloppyclockflag |= in->flags & CLK_FLAG1; in refclock_control()
1295 if (in->haveflags & CLK_HAVEFLAG2) { in refclock_control()
1296 pp->sloppyclockflag &= ~CLK_FLAG2; in refclock_control()
1297 pp->sloppyclockflag |= in->flags & CLK_FLAG2; in refclock_control()
1299 if (in->haveflags & CLK_HAVEFLAG3) { in refclock_control()
1300 pp->sloppyclockflag &= ~CLK_FLAG3; in refclock_control()
1301 pp->sloppyclockflag |= in->flags & CLK_FLAG3; in refclock_control()
1303 if (in->haveflags & CLK_HAVEFLAG4) { in refclock_control()
1304 pp->sloppyclockflag &= ~CLK_FLAG4; in refclock_control()
1305 pp->sloppyclockflag |= in->flags & CLK_FLAG4; in refclock_control()
1307 if (in->haveflags & CLK_HAVEMINJIT) in refclock_control()
1308 pp->fudgeminjitter = in->fudgeminjitter; in refclock_control()
1315 out->fudgeval1 = pp->stratum; in refclock_control()
1316 out->fudgeval2 = pp->refid; in refclock_control()
1317 out->haveflags = CLK_HAVEVAL1 | CLK_HAVEVAL2; in refclock_control()
1318 out->fudgetime1 = pp->fudgetime1; in refclock_control()
1319 if (0.0 != out->fudgetime1) in refclock_control()
1320 out->haveflags |= CLK_HAVETIME1; in refclock_control()
1321 out->fudgetime2 = pp->fudgetime2; in refclock_control()
1322 if (0.0 != out->fudgetime2) in refclock_control()
1323 out->haveflags |= CLK_HAVETIME2; in refclock_control()
1324 out->flags = (u_char) pp->sloppyclockflag; in refclock_control()
1325 if (CLK_FLAG1 & out->flags) in refclock_control()
1326 out->haveflags |= CLK_HAVEFLAG1; in refclock_control()
1327 if (CLK_FLAG2 & out->flags) in refclock_control()
1328 out->haveflags |= CLK_HAVEFLAG2; in refclock_control()
1329 if (CLK_FLAG3 & out->flags) in refclock_control()
1330 out->haveflags |= CLK_HAVEFLAG3; in refclock_control()
1331 if (CLK_FLAG4 & out->flags) in refclock_control()
1332 out->haveflags |= CLK_HAVEFLAG4; in refclock_control()
1333 out->fudgeminjitter = pp->fudgeminjitter; in refclock_control()
1334 if (0.0 != out->fudgeminjitter) in refclock_control()
1335 out->haveflags |= CLK_HAVEMINJIT; in refclock_control()
1337 out->timereset = current_time - pp->timestarted; in refclock_control()
1338 out->polls = pp->polls; in refclock_control()
1339 out->noresponse = pp->noreply; in refclock_control()
1340 out->badformat = pp->badformat; in refclock_control()
1341 out->baddata = pp->baddata; in refclock_control()
1343 out->lastevent = pp->lastevent; in refclock_control()
1344 out->currentstatus = pp->currentstatus; in refclock_control()
1345 out->type = pp->type; in refclock_control()
1346 out->clockdesc = pp->clockdesc; in refclock_control()
1347 out->lencode = (u_short)pp->lencode; in refclock_control()
1348 out->p_lastcode = pp->a_lastcode; in refclock_control()
1354 if (refclock_conf[clktype]->clock_control != noentry) in refclock_control()
1355 (refclock_conf[clktype]->clock_control)(unit, in, out, peer); in refclock_control()
1360 * refclock_buginfo - return debugging info
1387 peer = findexistingpeer(srcadr, NULL, NULL, -1, 0, NULL); in refclock_buginfo()
1389 if (NULL == peer || NULL == peer->procptr) in refclock_buginfo()
1392 pp = peer->procptr; in refclock_buginfo()
1397 bug->nvalues = 8; in refclock_buginfo()
1398 bug->svalues = 0x0000003f; in refclock_buginfo()
1399 bug->values[0] = pp->year; in refclock_buginfo()
1400 bug->values[1] = pp->day; in refclock_buginfo()
1401 bug->values[2] = pp->hour; in refclock_buginfo()
1402 bug->values[3] = pp->minute; in refclock_buginfo()
1403 bug->values[4] = pp->second; in refclock_buginfo()
1404 bug->values[5] = pp->nsec; in refclock_buginfo()
1405 bug->values[6] = pp->yearstart; in refclock_buginfo()
1406 bug->values[7] = pp->coderecv; in refclock_buginfo()
1407 bug->stimes = 0xfffffffc; in refclock_buginfo()
1408 bug->times[0] = pp->lastref; in refclock_buginfo()
1409 bug->times[1] = pp->lastrec; in refclock_buginfo()
1410 for (u = 2; u < bug->ntimes; u++) in refclock_buginfo()
1411 DTOLFP(pp->filter[u - 2], &bug->times[u]); in refclock_buginfo()
1416 if (refclock_conf[clktype]->clock_buginfo != noentry) in refclock_buginfo()
1417 (refclock_conf[clktype]->clock_buginfo)(unit, bug, peer); in refclock_buginfo()
1423 * refclock_ppsapi - initialize/update ppsapi
1434 if (ap->handle == 0) { in refclock_ppsapi()
1435 if (time_pps_create(fddev, &ap->handle) < 0) { in refclock_ppsapi()
1440 ZERO(ap->ts); /* [Bug 2689] defined INIT state */ in refclock_ppsapi()
1447 * refclock_params - set ppsapi parameters
1458 ZERO(ap->pps_params); in refclock_params()
1459 ap->pps_params.api_version = PPS_API_VERS_1; in refclock_params()
1468 ap->pps_params.mode = PPS_TSFMT_TSPEC | PPS_CAPTURECLEAR; in refclock_params()
1470 ap->pps_params.mode = PPS_TSFMT_TSPEC | PPS_CAPTUREASSERT; in refclock_params()
1471 if (time_pps_setparams(ap->handle, &ap->pps_params) < 0) { in refclock_params()
1485 if (time_pps_kcbind(ap->handle, PPS_KC_HARDPPS, in refclock_params()
1486 ap->pps_params.mode & ~PPS_TSFMT_TSPEC, in refclock_params()
1503 * refclock_pps - called once per second
1506 * timestamp from the kernel and saves the sign-extended fraction in
1526 pp = peer->procptr; in refclock_pps()
1527 if (ap->handle == 0) in refclock_pps()
1530 if (ap->pps_params.mode == 0 && sys_leap != LEAP_NOTINSYNC) { in refclock_pps()
1531 if (refclock_params(pp->sloppyclockflag, ap) < 1) in refclock_pps()
1536 if (time_pps_fetch(ap->handle, PPS_TSFMT_TSPEC, &pps_info, in refclock_pps()
1541 timeout = ap->ts; /* save old timestamp for check */ in refclock_pps()
1542 if (ap->pps_params.mode & PPS_CAPTUREASSERT) in refclock_pps()
1543 ap->ts = pps_info.assert_timestamp; in refclock_pps()
1544 else if (ap->pps_params.mode & PPS_CAPTURECLEAR) in refclock_pps()
1545 ap->ts = pps_info.clear_timestamp; in refclock_pps()
1549 /* [Bug 2689] Discard the first sample we read -- if the PPS in refclock_pps()
1552 * is all-zero, we consider this sample unrealiable and drop it. in refclock_pps()
1558 * Note 2: If we ever again get an all-zero PPS sample, the next in refclock_pps()
1569 if (0 == memcmp(&timeout, &ap->ts, sizeof(timeout))) in refclock_pps()
1574 * fold the correction into the [-0.5s,0.5s] range. Handle in refclock_pps()
1577 dtemp = ap->ts.tv_nsec / 1e9; in refclock_pps()
1578 dcorr = modf((pp->fudgetime1 - dtemp), &trash); in refclock_pps()
1580 dcorr -= 1.0; in refclock_pps()
1581 else if (dcorr < -0.5) in refclock_pps()
1584 /* phase gate check: avoid wobbling by +/-1s when too close to in refclock_pps()
1585 * the switch-over point. We allow +/-400ms max phase deviation. in refclock_pps()
1586 * The trade-off is clear: The smaller the limit, the less in refclock_pps()
1588 * system must get into phase gate range by other means for the in refclock_pps()
1597 pp->lastrec.l_ui = (u_int32)ap->ts.tv_sec + JAN_1970; in refclock_pps()
1598 pp->lastrec.l_uf = (u_int32)(dtemp * FRAC); in refclock_pps()
1605 dcorr, pp->fudgetime1); in refclock_pps()
1613 * -------------------------------------------------------------------
1614 * refclock_ppsaugment(...) -- correlate with PPS edge
1622 * driver does, but we deal with full time stamps here, not just phase
1623 * shift information.) Likewise, a negative fudge time2 value must be
1629 * +/-100ms precision should be enough. But since the fudge value will
1641 * - no PPS/ATOM unit given
1642 * - PPS stamp is stale (that is, the difference between the PPS stamp
1644 * - The phase difference is too close to 0.5, and the decision wether
1649 * -------------------------------------------------------------------
1667 uint32_t phase; in refclock_ppsaugment() local
1683 if (time_pps_fetch(ap->handle, PPS_TSFMT_TSPEC, in refclock_ppsaugment()
1688 if (ap->pps_params.mode & PPS_CAPTUREASSERT) in refclock_ppsaugment()
1690 else if (ap->pps_params.mode & PPS_CAPTURECLEAR) in refclock_ppsaugment()
1700 /* Get difference between PPS stamp (--> yield) and receive time in refclock_ppsaugment()
1701 * (--> base) in refclock_ppsaugment()
1709 phase = delta->l_ui; in refclock_ppsaugment()
1710 if (phase >= 2 && phase < (uint32_t)-2) in refclock_ppsaugment()
1713 /* If the phase is too close to 0.5, the decision whether to in refclock_ppsaugment()
1721 phase = delta->l_uf; in refclock_ppsaugment()
1722 if (phase > s_plim_hi && phase < s_plim_lo) in refclock_ppsaugment()
1725 /* sign-extend fraction into seconds */ in refclock_ppsaugment()
1726 delta->l_ui = UINT32_C(0) - ((phase >> 31) & 1); in refclock_ppsaugment()
1745 * -------------------------------------------------------------------
1763 if (pp->inpoll || (peer->procptr != pp) || in refclock_checkburst()
1764 ((peer->reach == 0xFF) && (peer->disp <= MAXDISTANCE))) in refclock_checkburst()
1769 if (peer->nextdate <= limit) in refclock_checkburst()
1775 needs = peer->reach; in refclock_checkburst()
1776 needs -= (needs >> 1) & 0x55; in refclock_checkburst()
1788 * re-adjusted, but maybe some time the hint will work...) in refclock_checkburst()
1790 peer->hpoll = peer->minpoll; in refclock_checkburst()
1791 peer->nextdate = limit; in refclock_checkburst()
1795 * -------------------------------------------------------------------
1806 if (len == (size_t)-1) in refclock_save_lcode()
1807 len = strnlen(tc, sizeof(pp->a_lastcode) - 1); in refclock_save_lcode()
1808 else if (len >= sizeof(pp->a_lastcode)) in refclock_save_lcode()
1809 len = sizeof(pp->a_lastcode) - 1; in refclock_save_lcode()
1811 pp->lencode = (u_short)len; in refclock_save_lcode()
1812 memcpy(pp->a_lastcode, tc, len); in refclock_save_lcode()
1813 pp->a_lastcode[len] = '\0'; in refclock_save_lcode()
1826 len = vsnprintf(pp->a_lastcode, sizeof(pp->a_lastcode), fmt, va); in refclock_vformat_lcode()
1829 } else if (len >= sizeof(pp->a_lastcode)) { in refclock_vformat_lcode()
1830 len = sizeof(pp->a_lastcode) - 1; in refclock_vformat_lcode()
1833 pp->lencode = (u_short)len; in refclock_vformat_lcode()
1834 pp->a_lastcode[len] = '\0'; in refclock_vformat_lcode()