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