Lines Matching refs:up

264  * offsets vary up to 0.3 ms due to ionospheric layer height variations.
448 chu_start, /* start up driver */
467 struct chuunit *up;
513 up = emalloc_zero(sizeof(*up));
515 pp->unitptr = up;
523 free(up);
533 strlcpy(up->ident, "CHU", sizeof(up->ident));
534 memcpy(&pp->refid, up->ident, 4);
535 DTOLFP(CHAR, &up->charstamp);
543 up->fd_audio = fd_audio;
544 up->gain = 127;
545 up->comp[0] = up->comp[OFFSET] = 0.;
546 up->comp[1] = 1; up->comp[OFFSET + 1] = -1.;
547 up->comp[2] = 3; up->comp[OFFSET + 2] = -3.;
550 up->comp[i] = up->comp[i - 1] + step;
551 up->comp[OFFSET + i] = -up->comp[i];
555 DTOLFP(1. / SECOND, &up->tick);
565 up->fd_icom = icom_init("/dev/icom", B1200,
568 up->fd_icom = icom_init("/dev/icom", B9600,
571 if (up->fd_icom > 0) {
574 close(up->fd_icom);
575 up->fd_icom = 0;
594 struct chuunit *up;
598 up = pp->unitptr;
599 if (up == NULL)
604 if (up->fd_icom > 0)
605 close(up->fd_icom);
607 free(up);
620 struct chuunit *up;
626 up = pp->unitptr;
629 * If the audio codec is warmed up, the buffer contains codec
636 if (up->fd_audio > 0)
655 struct chuunit *up;
666 up = pp->unitptr;
674 up->timestamp = rbufp->recv_time;
677 sample = up->comp[~*dpt++ & 0xff];
686 up->clipcnt++;
689 up->clipcnt++;
692 L_ADD(&up->timestamp, &up->tick);
697 up->seccnt = (up->seccnt + 1) % SECOND;
698 if (up->seccnt == 0) {
707 up->port = 2;
709 up->port = 1;
711 up->mongain = MONGAIN;
713 up->mongain = 0;
737 struct chuunit *up;
751 up = pp->unitptr;
758 signal = (up->bpf[8] = up->bpf[7]) * 5.844676e-01;
759 signal += (up->bpf[7] = up->bpf[6]) * 4.884860e-01;
760 signal += (up->bpf[6] = up->bpf[5]) * 2.704384e+00;
761 signal += (up->bpf[5] = up->bpf[4]) * 1.645032e+00;
762 signal += (up->bpf[4] = up->bpf[3]) * 4.644557e+00;
763 signal += (up->bpf[3] = up->bpf[2]) * 1.879165e+00;
764 signal += (up->bpf[2] = up->bpf[1]) * 3.522634e+00;
765 signal += (up->bpf[1] = up->bpf[0]) * 7.315738e-01;
766 up->bpf[0] = sample - signal;
767 signal = up->bpf[0] * 6.176213e-03
768 + up->bpf[1] * 3.156599e-03
769 + up->bpf[2] * 7.567487e-03
770 + up->bpf[3] * 4.344580e-03
771 + up->bpf[4] * 1.190128e-02
772 + up->bpf[5] * 4.344580e-03
773 + up->bpf[6] * 7.567487e-03
774 + up->bpf[7] * 3.156599e-03
775 + up->bpf[8] * 6.176213e-03;
777 up->monitor = signal / 4.; /* note monitor after filter */
793 disc = up->disc[up->discptr] * -limit;
794 up->disc[up->discptr] = limit;
795 up->discptr = (up->discptr + 1 ) % LAG;
804 lpf = (up->lpf[26] = up->lpf[25]) * 2.538771e-02;
805 lpf += (up->lpf[25] = up->lpf[24]) * 1.084671e-01;
806 lpf += (up->lpf[24] = up->lpf[23]) * 2.003159e-01;
807 lpf += (up->lpf[23] = up->lpf[22]) * 2.985303e-01;
808 lpf += (up->lpf[22] = up->lpf[21]) * 4.003697e-01;
809 lpf += (up->lpf[21] = up->lpf[20]) * 5.028552e-01;
810 lpf += (up->lpf[20] = up->lpf[19]) * 6.028795e-01;
811 lpf += (up->lpf[19] = up->lpf[18]) * 6.973249e-01;
812 lpf += (up->lpf[18] = up->lpf[17]) * 7.831828e-01;
813 lpf += (up->lpf[17] = up->lpf[16]) * 8.576717e-01;
814 lpf += (up->lpf[16] = up->lpf[15]) * 9.183463e-01;
815 lpf += (up->lpf[15] = up->lpf[14]) * 9.631951e-01;
816 lpf += (up->lpf[14] = up->lpf[13]) * 9.907208e-01;
817 lpf += (up->lpf[13] = up->lpf[12]) * 1.000000e+00;
818 lpf += (up->lpf[12] = up->lpf[11]) * 9.907208e-01;
819 lpf += (up->lpf[11] = up->lpf[10]) * 9.631951e-01;
820 lpf += (up->lpf[10] = up->lpf[9]) * 9.183463e-01;
821 lpf += (up->lpf[9] = up->lpf[8]) * 8.576717e-01;
822 lpf += (up->lpf[8] = up->lpf[7]) * 7.831828e-01;
823 lpf += (up->lpf[7] = up->lpf[6]) * 6.973249e-01;
824 lpf += (up->lpf[6] = up->lpf[5]) * 6.028795e-01;
825 lpf += (up->lpf[5] = up->lpf[4]) * 5.028552e-01;
826 lpf += (up->lpf[4] = up->lpf[3]) * 4.003697e-01;
827 lpf += (up->lpf[3] = up->lpf[2]) * 2.985303e-01;
828 lpf += (up->lpf[2] = up->lpf[1]) * 2.003159e-01;
829 lpf += (up->lpf[1] = up->lpf[0]) * 1.084671e-01;
830 lpf += up->lpf[0] = disc * 2.538771e-02;
841 up->baud += 1. / SECOND;
842 if (up->baud > 1. / (BAUD * 8.)) {
843 up->baud -= 1. / (BAUD * 8.);
844 up->decptr = (up->decptr + 1) % 8;
845 sp = &up->surv[up->decptr];
846 sp->cstamp = up->timestamp;
848 if (up->dbrk > 0) {
849 up->dbrk--;
850 if (up->dbrk > 0)
853 up->decpha = up->decptr;
855 if (up->decptr != up->decpha)
867 if ((up->surv[i].uart & 0x601) != 0x600 ||
868 up->surv[i].span < SPAN)
871 if (up->surv[i].dist > dist) {
872 dist = up->surv[i].dist;
885 up->maxsignal = up->surv[j].span;
886 chu_decode(peer, (up->surv[j].uart >> 1) & 0xff,
887 up->surv[j].cstamp);
888 up->dbrk = 88;
992 struct chuunit *up;
998 up = pp->unitptr;
1006 tstmp = up->timestamp;
1007 if (L_ISZERO(&up->laststamp))
1008 up->laststamp = up->timestamp;
1009 L_SUB(&tstmp, &up->laststamp);
1010 up->laststamp = up->timestamp;
1014 up->ndx = 0;
1016 up->ndx = 0;
1023 if (up->ndx < BURST) {
1024 up->cbuf[up->ndx] = hexhex & 0xff;
1025 up->cstamp[up->ndx] = cstamp;
1026 up->ndx++;
1040 struct chuunit *up;
1046 up = pp->unitptr;
1054 if (up->ndx < MINCHARS) {
1055 up->status |= RUNT;
1058 up->burdist = 0;
1059 for (i = 0; i < 5 && i < up->ndx - 5; i++)
1060 up->burdist += chu_dist(up->cbuf[i], up->cbuf[i + 5]);
1069 if (up->burdist >= MINDIST) {
1070 chu_a(peer, up->ndx);
1071 } else if (up->burdist <= -MINDIST) {
1072 chu_b(peer, up->ndx);
1074 up->status |= NOISE;
1099 struct chuunit *up;
1109 up = pp->unitptr;
1119 up->status, up->maxsignal, nchar, -up->burdist);
1130 snprintf(p, cb, "%02x", up->cbuf[i]);
1138 if (up->burdist > -40) {
1139 up->status |= BFRAME;
1148 code[2 * i] = hexchar[up->cbuf[i] & 0xf];
1149 code[2 * i + 1] = hexchar[(up->cbuf[i] >>
1152 if (sscanf((char *)code, "%1x%1d%4d%2d%2x", &up->leap, &up->dut,
1153 &pp->year, &up->tai, &up->dst) != 5) {
1154 up->status |= BFORMAT;
1157 up->status |= BVALID;
1158 if (up->leap & 0x8)
1159 up->dut = -up->dut;
1173 struct chuunit *up;
1185 up = pp->unitptr;
1196 up->syndist = k = 0;
1199 temp = up->cbuf[i + 4] & 0xf;
1201 temp |= (up->cbuf[i] & 0xf) << 4;
1203 temp = (up->cbuf[i + 5] & 0xf) << 4;
1205 temp |= up->cbuf[i + 9] & 0xf;
1207 if (val > up->syndist) {
1208 up->syndist = val;
1217 temp = (up->cbuf[k + 4] >> 4) & 0xf;
1219 ((up->cbuf[k + 9] >> 4) & 0xf))
1222 "chuA %04x %4.0f %2d %2d %2d %2d %1d ", up->status,
1223 up->maxsignal, nchar, up->burdist, k, up->syndist,
1235 snprintf(p, cb, "%02x", up->cbuf[i]);
1243 if (up->syndist < MINSYNC) {
1244 up->status |= AFRAME;
1256 up->status |= AFORMAT;
1258 up->status |= AVALID;
1259 up->second = pp->second = 30 + temp;
1264 offset = up->charstamp;
1268 up->tstamp[up->ntstamp] = up->cstamp[i];
1269 L_SUB(&up->tstamp[up->ntstamp], &offset);
1270 L_ADD(&offset, &up->charstamp);
1271 if (up->ntstamp < MAXSTAGE - 1)
1272 up->ntstamp++;
1274 while (temp > up->prevsec) {
1276 up->decode[9][j] = up->decode[9][j - 1];
1277 up->decode[19][j] =
1278 up->decode[19][j - 1];
1280 up->decode[9][j] = up->decode[19][j] = 0;
1281 up->prevsec++;
1294 up->decode[i][up->cbuf[j] & 0xf]++;
1296 up->decode[i][(up->cbuf[j] >> 4) & 0xf]++;
1299 up->burstcnt++;
1329 struct chuunit *up;
1336 up = pp->unitptr;
1343 up->second = (up->second + 1) % 60;
1344 if (up->second != 0)
1357 if (up->status & (BFRAME | AFRAME))
1359 if (up->status & (BFORMAT | AFORMAT))
1361 if (up->status & DECODE)
1363 if (up->status & STAMP)
1365 if (up->status & BVALID && dtemp >= MINMETRIC)
1366 up->status |= INSYNC;
1368 if (!(up->status & INSYNC)) {
1371 } else if (up->leap & 0x2) {
1374 } else if (up->leap & 0x4) {
1383 pp->second, leapchar, up->dst, up->dut, minset, up->gain,
1384 up->ident, dtemp, up->ntstamp);
1392 if (up->status & INSYNC && !(up->status & (DECODE | STAMP)) &&
1395 up->tstamp[0].l_ui, &pp->yearstart, &offset.l_ui)) {
1396 up->errflg = CEVNT_BADTIME;
1399 for (i = 0; i < up->ntstamp; i++)
1401 up->tstamp[i], PDELAY +
1403 pp->lastref = up->timestamp;
1418 if (up->errflg)
1419 refclock_report(peer, up->errflg);
1420 up->errflg = 0;
1433 struct chuunit *up;
1443 up = pp->unitptr;
1463 temp = up->decode[i][j] + up->decode[i + 10][j];
1469 if (val1 <= up->burstcnt)
1470 up->status |= DECODE;
1484 up->status |= DECODE;
1485 if (up->ntstamp < MINSTAMP)
1486 up->status |= STAMP;
1500 struct chuunit *up;
1504 up = pp->unitptr;
1509 up->ndx = up->prevsec = 0;
1510 up->burstcnt = up->ntstamp = 0;
1511 up->status &= INSYNC | METRIC;
1514 up->decode[i][j] = 0;
1529 struct chuunit *up;
1537 up = pp->unitptr;
1548 if (up->fd_icom <= 0)
1555 sp = &up->xmtr[up->chan];
1563 up->xmtr[i].probe++;
1564 if (up->xmtr[i].metric > metric) {
1565 up->status |= METRIC;
1566 metric = up->xmtr[i].metric;
1567 up->chan = i;
1575 up->dwell = (up->dwell + 1) % DWELL;
1576 if (up->dwell == 0 || metric == 0) {
1579 if (up->xmtr[i].probe > rval) {
1580 rval = up->xmtr[i].probe;
1581 up->chan = i;
1589 rval = icom_freq(up->fd_icom, peer->ttl & 0x7f, qsy[up->chan] +
1591 snprintf(up->ident, sizeof(up->ident), "CHU%d", up->chan);
1592 memcpy(&pp->refid, up->ident, 4);
1593 memcpy(&peer->refid, up->ident, 4);
1594 if (metric == 0 && up->status & METRIC) {
1595 up->status &= ~METRIC;
1641 * there are no clips, the gain is bumped up; if there are more than
1652 struct chuunit *up;
1655 up = pp->unitptr;
1662 if (up->clipcnt == 0) {
1663 up->gain += 4;
1664 if (up->gain > MAXGAIN)
1665 up->gain = MAXGAIN;
1666 } else if (up->clipcnt > MAXCLP) {
1667 up->gain -= 4;
1668 if (up->gain < 0)
1669 up->gain = 0;
1671 audio_gain(up->gain, up->mongain, up->port);
1672 up->clipcnt = 0;