Lines Matching full:up
244 * offsets vary up to 0.3 ms due to ionosperhic layer height variations.
509 * WWV unit control structure (up)
616 wwv_start, /* start up driver */
636 struct wwvunit *up; in wwv_start() local
662 up = emalloc_zero(sizeof(*up)); in wwv_start()
670 free(up); in wwv_start()
673 pp->unitptr = up; in wwv_start()
685 up->comp[0] = up->comp[OFFSET] = 0.; in wwv_start()
686 up->comp[1] = 1.; up->comp[OFFSET + 1] = -1.; in wwv_start()
687 up->comp[2] = 3.; up->comp[OFFSET + 2] = -3.; in wwv_start()
690 up->comp[i] = up->comp[i - 1] + step; in wwv_start()
691 up->comp[OFFSET + i] = -up->comp[i]; in wwv_start()
695 DTOLFP(1. / WWV_SEC, &up->tick); in wwv_start()
701 up->decvec[MN].radix = 10; /* minutes */ in wwv_start()
702 up->decvec[MN + 1].radix = 6; in wwv_start()
703 up->decvec[HR].radix = 10; /* hours */ in wwv_start()
704 up->decvec[HR + 1].radix = 3; in wwv_start()
705 up->decvec[DA].radix = 10; /* days */ in wwv_start()
706 up->decvec[DA + 1].radix = 10; in wwv_start()
707 up->decvec[DA + 2].radix = 4; in wwv_start()
708 up->decvec[YR].radix = 10; /* years */ in wwv_start()
709 up->decvec[YR + 1].radix = 10; in wwv_start()
726 up->fd_icom = icom_init("/dev/icom", B1200, in wwv_start()
729 up->fd_icom = icom_init("/dev/icom", B9600, in wwv_start()
732 if (up->fd_icom > 0) { in wwv_start()
735 close(up->fd_icom); in wwv_start()
736 up->fd_icom = 0; in wwv_start()
761 struct wwvunit *up; in wwv_shutdown() local
764 up = pp->unitptr; in wwv_shutdown()
765 if (up == NULL) in wwv_shutdown()
770 if (up->fd_icom > 0) in wwv_shutdown()
771 close(up->fd_icom); in wwv_shutdown()
773 free(up); in wwv_shutdown()
792 struct wwvunit *up; in wwv_receive() local
804 up = pp->unitptr; in wwv_receive()
812 up->timestamp = rbufp->recv_time; in wwv_receive()
815 sample = up->comp[~*dpt++ & 0xff]; in wwv_receive()
824 up->clipcnt++; in wwv_receive()
827 up->clipcnt++; in wwv_receive()
838 up->phase += (up->freq + clock_codec) / WWV_SEC; in wwv_receive()
839 if (up->phase >= .5) { in wwv_receive()
840 up->phase -= 1.; in wwv_receive()
841 } else if (up->phase < -.5) { in wwv_receive()
842 up->phase += 1.; in wwv_receive()
848 L_ADD(&up->timestamp, &up->tick); in wwv_receive()
855 up->port = 2; in wwv_receive()
857 up->port = 1; in wwv_receive()
859 up->mongain = MONGAIN; in wwv_receive()
861 up->mongain = 0; in wwv_receive()
880 struct wwvunit *up; in wwv_poll() local
883 up = pp->unitptr; in wwv_poll()
884 if (up->errflg) in wwv_poll()
885 refclock_report(peer, up->errflg); in wwv_poll()
886 up->errflg = 0; in wwv_poll()
928 struct wwvunit *up; in wwv_rf() local
977 up = pp->unitptr; in wwv_rf()
1032 i = up->datapt; in wwv_rf()
1033 up->datapt = (up->datapt + IN100) % 80; in wwv_rf()
1035 up->irig -= ibuf[iptr]; in wwv_rf()
1037 up->irig += dtemp; in wwv_rf()
1041 up->qrig -= qbuf[iptr]; in wwv_rf()
1043 up->qrig += dtemp; in wwv_rf()
1094 up->mphase = (up->mphase + 1) % WWV_MIN; in wwv_rf()
1095 epoch = up->mphase % WWV_SEC; in wwv_rf()
1120 sp = &up->mitig[up->achan].wwv; in wwv_rf()
1122 if (!(up->status & MSYNC)) in wwv_rf()
1148 rp = &up->mitig[up->achan].wwvh; in wwv_rf()
1150 if (!(up->status & MSYNC)) in wwv_rf()
1159 if (up->mphase == 0) { in wwv_rf()
1160 up->watch++; in wwv_rf()
1161 if (!(up->status & MSYNC)) { in wwv_rf()
1170 up->watch = 0; in wwv_rf()
1178 if (up->status & LEPSEC) { in wwv_rf()
1179 up->mphase -= WWV_SEC; in wwv_rf()
1180 if (up->mphase < 0) in wwv_rf()
1181 up->mphase += WWV_MIN; in wwv_rf()
1196 * clock drifts more than that, it might wind up in the wrong in wwv_rf()
1201 if (up->status & MSYNC) { in wwv_rf()
1203 } else if (up->sptr != NULL) { in wwv_rf()
1204 sp = up->sptr; in wwv_rf()
1207 up->rsec = (60 - sp->mepoch / WWV_SEC) % 60; in wwv_rf()
1208 up->rphase = 0; in wwv_rf()
1209 up->status |= MSYNC; in wwv_rf()
1210 up->watch = 0; in wwv_rf()
1211 if (!(up->status & SSYNC)) in wwv_rf()
1212 up->repoch = up->yepoch = epoch; in wwv_rf()
1214 up->repoch = up->yepoch; in wwv_rf()
1226 if (up->status & SELV) in wwv_rf()
1229 else if (up->status & SELH) in wwv_rf()
1247 up->avgint); in wwv_rf()
1259 up->epomax = epomax; in wwv_rf()
1260 up->eposnr = wwv_snr(epomax, nxtmax); in wwv_rf()
1265 if (!(up->status & SSYNC)) in wwv_rf()
1266 up->alarm |= SYNERR; in wwv_rf()
1268 if (!(up->status & MSYNC)) in wwv_rf()
1302 struct wwvunit *up; in wwv_qrz() local
1307 up = pp->unitptr; in wwv_qrz()
1314 epoch = up->mphase - pdelay - SYNSIZ; in wwv_qrz()
1330 if (up->mphase == 0) { in wwv_qrz()
1349 if (up->watch > ACQSN) in wwv_qrz()
1356 up->status, up->gain, sp->refid, in wwv_qrz()
1389 struct wwvunit *up; in wwv_endpoc() local
1408 up = pp->unitptr; in wwv_endpoc()
1421 if (up->epomax < STHR || up->eposnr < SSNR) { in wwv_endpoc()
1422 up->status &= ~(SSYNC | FGATE); in wwv_endpoc()
1426 if (!(up->status & (SELV | SELH))) in wwv_endpoc()
1462 * interval while the comb filter charges up and noise in wwv_endpoc()
1468 if (syncnt > SCMP && up->status & MSYNC && (up->status & in wwv_endpoc()
1469 FGATE || scount - zcount <= up->avgint)) { in wwv_endpoc()
1470 up->status |= SSYNC; in wwv_endpoc()
1471 up->yepoch = tepoch; in wwv_endpoc()
1479 if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status & in wwv_endpoc()
1483 up->status, up->gain, tepoch, up->epomax, in wwv_endpoc()
1484 up->eposnr, tmp2, avgcnt, syncnt, in wwv_endpoc()
1493 if (avgcnt < up->avgint) { in wwv_endpoc()
1542 if (up->status & FGATE) { in wwv_endpoc()
1544 up->freq += (dtemp / 2.) / ((mcount - zcount) * in wwv_endpoc()
1546 if (up->freq > MAXFREQ) in wwv_endpoc()
1547 up->freq = MAXFREQ; in wwv_endpoc()
1548 else if (up->freq < -MAXFREQ) in wwv_endpoc()
1549 up->freq = -MAXFREQ; in wwv_endpoc()
1554 if (up->avgint < MAXAVG) { in wwv_endpoc()
1555 up->avgint <<= 1; in wwv_endpoc()
1564 if (up->avgint > MINAVG) { in wwv_endpoc()
1565 up->avgint >>= 1; in wwv_endpoc()
1574 up->status, up->epomax, up->eposnr, mepoch, in wwv_endpoc()
1575 up->avgint, maxrun, mcount - zcount, dtemp, in wwv_endpoc()
1576 up->freq * 1e6 / WWV_SEC); in wwv_endpoc()
1585 * This is a valid update; set up for the next interval. in wwv_endpoc()
1587 up->status |= FGATE; in wwv_endpoc()
1619 struct wwvunit *up; in wwv_epoch() local
1624 up = pp->unitptr; in wwv_epoch()
1633 cp = &up->mitig[up->achan]; in wwv_epoch()
1638 if (up->rphase == 800 * MS) in wwv_epoch()
1639 up->repoch = up->yepoch; in wwv_epoch()
1650 if (up->rphase == 15 * MS) in wwv_epoch()
1651 sigmin = sigzer = sigone = up->irig; in wwv_epoch()
1659 if (up->rphase == 200 * MS) { in wwv_epoch()
1660 sigzer = up->irig; in wwv_epoch()
1661 engmax = sqrt(up->irig * up->irig + up->qrig * in wwv_epoch()
1662 up->qrig); in wwv_epoch()
1663 up->datpha = up->qrig / up->avgint; in wwv_epoch()
1664 if (up->datpha >= 0) { in wwv_epoch()
1665 up->datapt++; in wwv_epoch()
1666 if (up->datapt >= 80) in wwv_epoch()
1667 up->datapt -= 80; in wwv_epoch()
1669 up->datapt--; in wwv_epoch()
1670 if (up->datapt < 0) in wwv_epoch()
1671 up->datapt += 80; in wwv_epoch()
1680 else if (up->rphase == 500 * MS) in wwv_epoch()
1681 sigone = up->irig; in wwv_epoch()
1697 up->rphase++; in wwv_epoch()
1698 if (up->mphase % WWV_SEC == up->repoch) { in wwv_epoch()
1699 up->status &= ~(DGATE | BGATE); in wwv_epoch()
1700 engmin = sqrt(up->irig * up->irig + up->qrig * in wwv_epoch()
1701 up->qrig); in wwv_epoch()
1702 up->datsig = engmax; in wwv_epoch()
1703 up->datsnr = wwv_snr(engmax, engmin); in wwv_epoch()
1710 if (engmax < DTHR || up->datsnr < DSNR) { in wwv_epoch()
1711 up->status |= DGATE; in wwv_epoch()
1718 if (up->status & (DGATE | BGATE)) in wwv_epoch()
1719 up->errcnt++; in wwv_epoch()
1720 if (up->errcnt > MAXERR) in wwv_epoch()
1721 up->alarm |= LOWERR; in wwv_epoch()
1723 cp = &up->mitig[up->achan]; in wwv_epoch()
1726 up->rphase = 0; in wwv_epoch()
1755 struct wwvunit *up; in wwv_rsec() local
1762 up = pp->unitptr; in wwv_rsec()
1777 nsec = up->rsec; in wwv_rsec()
1778 up->rsec++; in wwv_rsec()
1811 cp = &up->mitig[up->achan]; in wwv_rsec()
1827 cp = &up->mitig[up->achan]; in wwv_rsec()
1838 !(up->status & (DGATE | BGATE))) { in wwv_rsec()
1853 !(up->status & (DGATE | BGATE))) { in wwv_rsec()
1861 up->status, up->gain, up->yepoch, in wwv_rsec()
1862 up->epomax, up->eposnr, up->datsig, in wwv_rsec()
1863 up->datsnr, in wwv_rsec()
1874 up->errcnt = up->digcnt = up->alarm = 0; in wwv_rsec()
1884 if (up->status & INSYNC) { in wwv_rsec()
1885 if (up->watch > PANIC) { in wwv_rsec()
1889 } else if (up->status & DSYNC) { in wwv_rsec()
1890 if (up->watch > SYNCH) { in wwv_rsec()
1894 } else if (up->watch > DATA) { in wwv_rsec()
1912 if (up->status & DSYNC) in wwv_rsec()
1929 wwv_corr4(peer, &up->decvec[arg], bcddld, bcd2); in wwv_rsec()
1933 wwv_corr4(peer, &up->decvec[arg], bcddld, bcd3); in wwv_rsec()
1937 wwv_corr4(peer, &up->decvec[arg], bcddld, bcd6); in wwv_rsec()
1941 wwv_corr4(peer, &up->decvec[arg], bcddld, bcd9); in wwv_rsec()
1951 wwv_corr4(peer, &up->decvec[YR + 1], bcddld, bcd9); in wwv_rsec()
1956 if (!(up->misc & arg)) in wwv_rsec()
1957 up->alarm |= CMPERR; in wwv_rsec()
1958 up->misc |= arg; in wwv_rsec()
1960 if (up->misc & arg) in wwv_rsec()
1961 up->alarm |= CMPERR; in wwv_rsec()
1962 up->misc &= ~arg; in wwv_rsec()
1964 up->status |= BGATE; in wwv_rsec()
1971 * light them back up. in wwv_rsec()
1975 if (!(up->misc & arg)) in wwv_rsec()
1976 up->alarm |= CMPERR; in wwv_rsec()
1977 up->misc |= arg; in wwv_rsec()
1979 if (up->misc & arg) in wwv_rsec()
1980 up->alarm |= CMPERR; in wwv_rsec()
1981 up->misc &= ~arg; in wwv_rsec()
1983 up->status |= BGATE; in wwv_rsec()
1985 up->status &= ~(SELV | SELH); in wwv_rsec()
1987 if (up->fd_icom > 0) { in wwv_rsec()
1988 up->schan = (up->schan + 1) % NCHAN; in wwv_rsec()
1989 wwv_qsy(peer, up->schan); in wwv_rsec()
1991 up->mitig[up->achan].gain = up->gain; in wwv_rsec()
1994 up->mitig[up->achan].gain = up->gain; in wwv_rsec()
2010 if (up->status & LEPSEC) in wwv_rsec()
2016 up->status &= ~LEPSEC; in wwv_rsec()
2018 up->rsec = 0; in wwv_rsec()
2022 if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status & in wwv_rsec()
2026 nsec, up->status, up->gain, up->yepoch, up->epomax, in wwv_rsec()
2027 up->eposnr, up->datsig, up->datsnr, bit); in wwv_rsec()
2054 struct wwvunit *up; in wwv_clock() local
2058 up = pp->unitptr; in wwv_clock()
2059 if (!(up->status & SSYNC)) in wwv_clock()
2060 up->alarm |= SYNERR; in wwv_clock()
2061 if (up->digcnt < 9) in wwv_clock()
2062 up->alarm |= NINERR; in wwv_clock()
2063 if (!(up->alarm)) in wwv_clock()
2064 up->status |= INSYNC; in wwv_clock()
2065 if (up->status & INSYNC && up->status & SSYNC) { in wwv_clock()
2066 if (up->misc & SECWAR) in wwv_clock()
2070 pp->second = up->rsec; in wwv_clock()
2071 pp->minute = up->decvec[MN].digit + up->decvec[MN + in wwv_clock()
2073 pp->hour = up->decvec[HR].digit + up->decvec[HR + in wwv_clock()
2075 pp->day = up->decvec[DA].digit + up->decvec[DA + in wwv_clock()
2076 1].digit * 10 + up->decvec[DA + 2].digit * 100; in wwv_clock()
2077 pp->year = up->decvec[YR].digit + up->decvec[YR + in wwv_clock()
2082 pp->second, GMT, up->timestamp.l_ui, in wwv_clock()
2084 up->errflg = CEVNT_BADTIME; in wwv_clock()
2086 up->watch = 0; in wwv_clock()
2088 pp->lastref = up->timestamp; in wwv_clock()
2090 up->timestamp, PDELAY + up->pdelay); in wwv_clock()
2094 pp->lencode = timecode(up, pp->a_lastcode, in wwv_clock()
2124 struct wwvunit *up; in wwv_corr4() local
2132 up = pp->unitptr; in wwv_corr4()
2174 up->status |= BGATE; in wwv_corr4()
2177 up->alarm |= CMPERR; in wwv_corr4()
2186 up->status |= DSYNC; in wwv_corr4()
2187 up->digcnt++; in wwv_corr4()
2191 if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status & in wwv_corr4()
2195 up->rsec - 1, up->status, up->gain, up->yepoch, in wwv_corr4()
2196 up->epomax, vp->radix, vp->digit, mldigit, in wwv_corr4()
2220 struct wwvunit *up; in wwv_tsec() local
2225 up = pp->unitptr; in wwv_tsec()
2231 temp = carry(&up->decvec[MN]); /* minute units */ in wwv_tsec()
2232 if (!(up->status & DSYNC)) in wwv_tsec()
2239 temp = carry(&up->decvec[MN + 1]); in wwv_tsec()
2241 temp = carry(&up->decvec[HR]); in wwv_tsec()
2243 temp = carry(&up->decvec[HR + 1]); in wwv_tsec()
2252 minute = up->decvec[MN].digit + up->decvec[MN + 1].digit * in wwv_tsec()
2253 10 + up->decvec[HR].digit * 60 + up->decvec[HR + in wwv_tsec()
2255 day = up->decvec[DA].digit + up->decvec[DA + 1].digit * 10 + in wwv_tsec()
2256 up->decvec[DA + 2].digit * 100; in wwv_tsec()
2261 isleap = up->decvec[YR].digit & 0x3; in wwv_tsec()
2262 if (up->misc & SECWAR && up->status & INSYNC) { in wwv_tsec()
2265 up->status |= LEPSEC; in wwv_tsec()
2276 while (carry(&up->decvec[HR]) != 0); /* advance to minute 0 */ in wwv_tsec()
2277 while (carry(&up->decvec[HR + 1]) != 0); in wwv_tsec()
2279 temp = carry(&up->decvec[DA]); /* carry days */ in wwv_tsec()
2281 temp = carry(&up->decvec[DA + 1]); in wwv_tsec()
2283 temp = carry(&up->decvec[DA + 2]); in wwv_tsec()
2294 while (carry(&up->decvec[DA]) != 1); /* advance to day 1 */ in wwv_tsec()
2295 while (carry(&up->decvec[DA + 1]) != 0); in wwv_tsec()
2296 while (carry(&up->decvec[DA + 2]) != 0); in wwv_tsec()
2297 temp = carry(&up->decvec[YR]); /* carry years */ in wwv_tsec()
2299 carry(&up->decvec[YR + 1]); in wwv_tsec()
2400 struct wwvunit *up; in wwv_newchan() local
2406 up = pp->unitptr; in wwv_newchan()
2416 rp = &up->mitig[i].wwvh; in wwv_newchan()
2423 rp = &up->mitig[i].wwv; in wwv_newchan()
2440 up->status &= ~(SELV | SELH); in wwv_newchan()
2442 up->dchan = (up->dchan + 1) % NCHAN; in wwv_newchan()
2443 if (up->status & METRIC) { in wwv_newchan()
2444 up->status &= ~METRIC; in wwv_newchan()
2449 up->dchan = j; in wwv_newchan()
2450 up->sptr = sp; in wwv_newchan()
2453 up->status |= METRIC; in wwv_newchan()
2455 up->status |= SELV; in wwv_newchan()
2456 up->pdelay = pp->fudgetime1; in wwv_newchan()
2458 up->status |= SELH; in wwv_newchan()
2459 up->pdelay = pp->fudgetime2; in wwv_newchan()
2461 up->pdelay = 0; in wwv_newchan()
2466 if (up->fd_icom > 0) in wwv_newchan()
2467 wwv_qsy(peer, up->dchan); in wwv_newchan()
2493 struct wwvunit *up; in wwv_newgame() local
2498 up = pp->unitptr; in wwv_newgame()
2504 if (up->status) in wwv_newgame()
2505 up->errflg = CEVNT_TIMEOUT; in wwv_newgame()
2507 up->watch = up->status = up->alarm = 0; in wwv_newgame()
2508 up->avgint = MINAVG; in wwv_newgame()
2509 up->freq = 0; in wwv_newgame()
2510 up->gain = MAXGAIN / 2; in wwv_newgame()
2518 memset(up->mitig, 0, sizeof(up->mitig)); in wwv_newgame()
2520 cp = &up->mitig[i]; in wwv_newgame()
2521 cp->gain = up->gain; in wwv_newgame()
2529 up->dchan = (DCHAN + NCHAN - 1) % NCHAN; in wwv_newgame()
2531 up->schan = up->dchan; in wwv_newgame()
2574 struct wwvunit *up; in wwv_qsy() local
2577 up = pp->unitptr; in wwv_qsy()
2578 if (up->fd_icom > 0) { in wwv_qsy()
2579 up->mitig[up->achan].gain = up->gain; in wwv_qsy()
2580 rval = icom_freq(up->fd_icom, peer->ttl & 0x7f, in wwv_qsy()
2582 up->achan = chan; in wwv_qsy()
2583 up->gain = up->mitig[up->achan].gain; in wwv_qsy()
2617 struct wwvunit *up, /* driver structure pointer */ in timecode() argument
2631 synchar = (up->status & INSYNC) ? ' ' : '?'; in timecode()
2632 year = up->decvec[YR].digit + up->decvec[YR + 1].digit * 10 + in timecode()
2634 day = up->decvec[DA].digit + up->decvec[DA + 1].digit * 10 + in timecode()
2635 up->decvec[DA + 2].digit * 100; in timecode()
2636 hour = up->decvec[HR].digit + up->decvec[HR + 1].digit * 10; in timecode()
2637 minute = up->decvec[MN].digit + up->decvec[MN + 1].digit * 10; in timecode()
2639 leapchar = (up->misc & SECWAR) ? 'L' : ' '; in timecode()
2640 dst = dstcod[(up->misc >> 4) & 0x3]; in timecode()
2641 dut = up->misc & 0x7; in timecode()
2642 if (!(up->misc & DUTS)) in timecode()
2644 snprintf(tc, tcsiz, "%c%1X", synchar, up->alarm); in timecode()
2653 sp = up->sptr; in timecode()
2655 up->watch, up->mitig[up->dchan].gain, sp->refid, in timecode()
2656 sp->metric, up->errcnt, up->freq / WWV_SEC * 1e6, in timecode()
2657 up->avgint); in timecode()
2669 * there are no clips, the gain is bumped up; if there are more than
2681 struct wwvunit *up; in wwv_gain() local
2684 up = pp->unitptr; in wwv_gain()
2691 if (up->clipcnt == 0) { in wwv_gain()
2692 up->gain += 4; in wwv_gain()
2693 if (up->gain > MAXGAIN) in wwv_gain()
2694 up->gain = MAXGAIN; in wwv_gain()
2695 } else if (up->clipcnt > MAXCLP) { in wwv_gain()
2696 up->gain -= 4; in wwv_gain()
2697 if (up->gain < 0) in wwv_gain()
2698 up->gain = 0; in wwv_gain()
2700 audio_gain(up->gain, up->mongain, up->port); in wwv_gain()
2701 up->clipcnt = 0; in wwv_gain()