Lines Matching refs:up

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