Lines Matching refs:up
266 * offsets vary up to 0.3 ms due to ionospheric layer height variations.
450 chu_start, /* start up driver */
469 struct chuunit *up;
515 up = emalloc_zero(sizeof(*up));
517 pp->unitptr = up;
525 free(up);
535 strlcpy(up->ident, "CHU", sizeof(up->ident));
536 memcpy(&pp->refid, up->ident, 4);
537 DTOLFP(CHAR, &up->charstamp);
545 up->fd_audio = fd_audio;
546 up->gain = 127;
547 up->comp[0] = up->comp[OFFSET] = 0.;
548 up->comp[1] = 1; up->comp[OFFSET + 1] = -1.;
549 up->comp[2] = 3; up->comp[OFFSET + 2] = -3.;
552 up->comp[i] = up->comp[i - 1] + step;
553 up->comp[OFFSET + i] = -up->comp[i];
557 DTOLFP(1. / SECOND, &up->tick);
567 up->fd_icom = icom_init("/dev/icom", B1200,
570 up->fd_icom = icom_init("/dev/icom", B9600,
573 if (up->fd_icom > 0) {
576 close(up->fd_icom);
577 up->fd_icom = 0;
596 struct chuunit *up;
600 up = pp->unitptr;
601 if (up == NULL)
606 if (up->fd_icom > 0)
607 close(up->fd_icom);
609 free(up);
622 struct chuunit *up;
628 up = pp->unitptr;
631 * If the audio codec is warmed up, the buffer contains codec
638 if (up->fd_audio > 0)
657 struct chuunit *up;
668 up = pp->unitptr;
676 up->timestamp = rbufp->recv_time;
679 sample = up->comp[~*dpt++ & 0xff];
688 up->clipcnt++;
691 up->clipcnt++;
694 L_ADD(&up->timestamp, &up->tick);
699 up->seccnt = (up->seccnt + 1) % SECOND;
700 if (up->seccnt == 0) {
709 up->port = 2;
711 up->port = 1;
713 up->mongain = MONGAIN;
715 up->mongain = 0;
739 struct chuunit *up;
753 up = pp->unitptr;
760 signal = (up->bpf[8] = up->bpf[7]) * 5.844676e-01;
761 signal += (up->bpf[7] = up->bpf[6]) * 4.884860e-01;
762 signal += (up->bpf[6] = up->bpf[5]) * 2.704384e+00;
763 signal += (up->bpf[5] = up->bpf[4]) * 1.645032e+00;
764 signal += (up->bpf[4] = up->bpf[3]) * 4.644557e+00;
765 signal += (up->bpf[3] = up->bpf[2]) * 1.879165e+00;
766 signal += (up->bpf[2] = up->bpf[1]) * 3.522634e+00;
767 signal += (up->bpf[1] = up->bpf[0]) * 7.315738e-01;
768 up->bpf[0] = sample - signal;
769 signal = up->bpf[0] * 6.176213e-03
770 + up->bpf[1] * 3.156599e-03
771 + up->bpf[2] * 7.567487e-03
772 + up->bpf[3] * 4.344580e-03
773 + up->bpf[4] * 1.190128e-02
774 + up->bpf[5] * 4.344580e-03
775 + up->bpf[6] * 7.567487e-03
776 + up->bpf[7] * 3.156599e-03
777 + up->bpf[8] * 6.176213e-03;
779 up->monitor = signal / 4.; /* note monitor after filter */
795 disc = up->disc[up->discptr] * -limit;
796 up->disc[up->discptr] = limit;
797 up->discptr = (up->discptr + 1 ) % LAG;
806 lpf = (up->lpf[26] = up->lpf[25]) * 2.538771e-02;
807 lpf += (up->lpf[25] = up->lpf[24]) * 1.084671e-01;
808 lpf += (up->lpf[24] = up->lpf[23]) * 2.003159e-01;
809 lpf += (up->lpf[23] = up->lpf[22]) * 2.985303e-01;
810 lpf += (up->lpf[22] = up->lpf[21]) * 4.003697e-01;
811 lpf += (up->lpf[21] = up->lpf[20]) * 5.028552e-01;
812 lpf += (up->lpf[20] = up->lpf[19]) * 6.028795e-01;
813 lpf += (up->lpf[19] = up->lpf[18]) * 6.973249e-01;
814 lpf += (up->lpf[18] = up->lpf[17]) * 7.831828e-01;
815 lpf += (up->lpf[17] = up->lpf[16]) * 8.576717e-01;
816 lpf += (up->lpf[16] = up->lpf[15]) * 9.183463e-01;
817 lpf += (up->lpf[15] = up->lpf[14]) * 9.631951e-01;
818 lpf += (up->lpf[14] = up->lpf[13]) * 9.907208e-01;
819 lpf += (up->lpf[13] = up->lpf[12]) * 1.000000e+00;
820 lpf += (up->lpf[12] = up->lpf[11]) * 9.907208e-01;
821 lpf += (up->lpf[11] = up->lpf[10]) * 9.631951e-01;
822 lpf += (up->lpf[10] = up->lpf[9]) * 9.183463e-01;
823 lpf += (up->lpf[9] = up->lpf[8]) * 8.576717e-01;
824 lpf += (up->lpf[8] = up->lpf[7]) * 7.831828e-01;
825 lpf += (up->lpf[7] = up->lpf[6]) * 6.973249e-01;
826 lpf += (up->lpf[6] = up->lpf[5]) * 6.028795e-01;
827 lpf += (up->lpf[5] = up->lpf[4]) * 5.028552e-01;
828 lpf += (up->lpf[4] = up->lpf[3]) * 4.003697e-01;
829 lpf += (up->lpf[3] = up->lpf[2]) * 2.985303e-01;
830 lpf += (up->lpf[2] = up->lpf[1]) * 2.003159e-01;
831 lpf += (up->lpf[1] = up->lpf[0]) * 1.084671e-01;
832 lpf += up->lpf[0] = disc * 2.538771e-02;
843 up->baud += 1. / SECOND;
844 if (up->baud > 1. / (BAUD * 8.)) {
845 up->baud -= 1. / (BAUD * 8.);
846 up->decptr = (up->decptr + 1) % 8;
847 sp = &up->surv[up->decptr];
848 sp->cstamp = up->timestamp;
850 if (up->dbrk > 0) {
851 up->dbrk--;
852 if (up->dbrk > 0)
855 up->decpha = up->decptr;
857 if (up->decptr != up->decpha)
869 if ((up->surv[i].uart & 0x601) != 0x600 ||
870 up->surv[i].span < SPAN)
873 if (up->surv[i].dist > dist) {
874 dist = up->surv[i].dist;
887 up->maxsignal = up->surv[j].span;
888 chu_decode(peer, (up->surv[j].uart >> 1) & 0xff,
889 up->surv[j].cstamp);
890 up->dbrk = 88;
994 struct chuunit *up;
1000 up = pp->unitptr;
1008 tstmp = up->timestamp;
1009 if (L_ISZERO(&up->laststamp))
1010 up->laststamp = up->timestamp;
1011 L_SUB(&tstmp, &up->laststamp);
1012 up->laststamp = up->timestamp;
1016 up->ndx = 0;
1018 up->ndx = 0;
1025 if (up->ndx < BURST) {
1026 up->cbuf[up->ndx] = hexhex & 0xff;
1027 up->cstamp[up->ndx] = cstamp;
1028 up->ndx++;
1042 struct chuunit *up;
1048 up = pp->unitptr;
1056 if (up->ndx < MINCHARS) {
1057 up->status |= RUNT;
1060 up->burdist = 0;
1061 for (i = 0; i < 5 && i < up->ndx - 5; i++)
1062 up->burdist += chu_dist(up->cbuf[i], up->cbuf[i + 5]);
1071 if (up->burdist >= MINDIST) {
1072 chu_a(peer, up->ndx);
1073 } else if (up->burdist <= -MINDIST) {
1074 chu_b(peer, up->ndx);
1076 up->status |= NOISE;
1101 struct chuunit *up;
1111 up = pp->unitptr;
1121 up->status, up->maxsignal, nchar, -up->burdist);
1132 snprintf(p, cb, "%02x", up->cbuf[i]);
1140 if (up->burdist > -40) {
1141 up->status |= BFRAME;
1150 code[2 * i] = hexchar[up->cbuf[i] & 0xf];
1151 code[2 * i + 1] = hexchar[(up->cbuf[i] >>
1154 if (sscanf((char *)code, "%1x%1d%4d%2d%2x", &up->leap, &up->dut,
1155 &pp->year, &up->tai, &up->dst) != 5) {
1156 up->status |= BFORMAT;
1159 up->status |= BVALID;
1160 if (up->leap & 0x8)
1161 up->dut = -up->dut;
1175 struct chuunit *up;
1187 up = pp->unitptr;
1198 up->syndist = k = 0;
1201 temp = up->cbuf[i + 4] & 0xf;
1203 temp |= (up->cbuf[i] & 0xf) << 4;
1205 temp = (up->cbuf[i + 5] & 0xf) << 4;
1207 temp |= up->cbuf[i + 9] & 0xf;
1209 if (val > up->syndist) {
1210 up->syndist = val;
1219 temp = (up->cbuf[k + 4] >> 4) & 0xf;
1221 ((up->cbuf[k + 9] >> 4) & 0xf))
1224 "chuA %04x %4.0f %2d %2d %2d %2d %1d ", up->status,
1225 up->maxsignal, nchar, up->burdist, k, up->syndist,
1237 snprintf(p, cb, "%02x", up->cbuf[i]);
1245 if (up->syndist < MINSYNC) {
1246 up->status |= AFRAME;
1258 up->status |= AFORMAT;
1260 up->status |= AVALID;
1261 up->second = pp->second = 30 + temp;
1266 offset = up->charstamp;
1270 up->tstamp[up->ntstamp] = up->cstamp[i];
1271 L_SUB(&up->tstamp[up->ntstamp], &offset);
1272 L_ADD(&offset, &up->charstamp);
1273 if (up->ntstamp < MAXSTAGE - 1)
1274 up->ntstamp++;
1276 while (temp > up->prevsec) {
1278 up->decode[9][j] = up->decode[9][j - 1];
1279 up->decode[19][j] =
1280 up->decode[19][j - 1];
1282 up->decode[9][j] = up->decode[19][j] = 0;
1283 up->prevsec++;
1296 up->decode[i][up->cbuf[j] & 0xf]++;
1298 up->decode[i][(up->cbuf[j] >> 4) & 0xf]++;
1301 up->burstcnt++;
1331 struct chuunit *up;
1338 up = pp->unitptr;
1345 up->second = (up->second + 1) % 60;
1346 if (up->second != 0)
1359 if (up->status & (BFRAME | AFRAME))
1361 if (up->status & (BFORMAT | AFORMAT))
1363 if (up->status & DECODE)
1365 if (up->status & STAMP)
1367 if (up->status & BVALID && dtemp >= MINMETRIC)
1368 up->status |= INSYNC;
1370 if (!(up->status & INSYNC)) {
1373 } else if (up->leap & 0x2) {
1376 } else if (up->leap & 0x4) {
1385 pp->second, leapchar, up->dst, up->dut, minset, up->gain,
1386 up->ident, dtemp, up->ntstamp);
1394 if (up->status & INSYNC && !(up->status & (DECODE | STAMP)) &&
1397 up->tstamp[0].l_ui, &pp->yearstart, &offset.l_ui)) {
1398 up->errflg = CEVNT_BADTIME;
1401 for (i = 0; i < up->ntstamp; i++)
1403 up->tstamp[i], PDELAY +
1405 pp->lastref = up->timestamp;
1420 if (up->errflg)
1421 refclock_report(peer, up->errflg);
1422 up->errflg = 0;
1435 struct chuunit *up;
1445 up = pp->unitptr;
1465 temp = up->decode[i][j] + up->decode[i + 10][j];
1471 if (val1 <= up->burstcnt)
1472 up->status |= DECODE;
1486 up->status |= DECODE;
1487 if (up->ntstamp < MINSTAMP)
1488 up->status |= STAMP;
1502 struct chuunit *up;
1506 up = pp->unitptr;
1511 up->ndx = up->prevsec = 0;
1512 up->burstcnt = up->ntstamp = 0;
1513 up->status &= INSYNC | METRIC;
1516 up->decode[i][j] = 0;
1531 struct chuunit *up;
1539 up = pp->unitptr;
1550 if (up->fd_icom <= 0)
1557 sp = &up->xmtr[up->chan];
1565 up->xmtr[i].probe++;
1566 if (up->xmtr[i].metric > metric) {
1567 up->status |= METRIC;
1568 metric = up->xmtr[i].metric;
1569 up->chan = i;
1577 up->dwell = (up->dwell + 1) % DWELL;
1578 if (up->dwell == 0 || metric == 0) {
1581 if (up->xmtr[i].probe > rval) {
1582 rval = up->xmtr[i].probe;
1583 up->chan = i;
1591 rval = icom_freq(up->fd_icom, peer->ttl & 0x7f, qsy[up->chan] +
1593 snprintf(up->ident, sizeof(up->ident), "CHU%d", up->chan);
1594 memcpy(&pp->refid, up->ident, 4);
1595 memcpy(&peer->refid, up->ident, 4);
1596 if (metric == 0 && up->status & METRIC) {
1597 up->status &= ~METRIC;
1643 * there are no clips, the gain is bumped up; if there are more than
1654 struct chuunit *up;
1657 up = pp->unitptr;
1664 if (up->clipcnt == 0) {
1665 up->gain += 4;
1666 if (up->gain > MAXGAIN)
1667 up->gain = MAXGAIN;
1668 } else if (up->clipcnt > MAXCLP) {
1669 up->gain -= 4;
1670 if (up->gain < 0)
1671 up->gain = 0;
1673 audio_gain(up->gain, up->mongain, up->port);
1674 up->clipcnt = 0;