Lines Matching +full:wait +full:- +full:free +full:- +full:us
2 * refclock_zyfer - clock driver for the Zyfer GPSTarplus Clock
38 * with arbitrary on-time characters. This clock *begins* the stream with
39 * `!`, the on-time character, and the string is *not* EOL-terminated.
41 * Configure the beast for 9600, 8N1. While I see leap-second stuff
50 * ! On-time character
52 * DDD 001-366 Day of Year
53 * HH 00-23 Hour
54 * MM 00-59 Minute
55 * SS 00-59 Second (probably 00-60)
56 * m 1-5 Time Mode:
62 * T 4-9 Time Figure Of Merit:
63 * 4 x <= 1us
64 * 5 1us < x <= 10 us
65 * 6 10us < x <= 100us
66 * 7 100us < x <= 1ms
69 * O 0-4 Operation Mode:
70 * 0 Warm-up
83 #define PRECISION (-20) /* precision assumed (about 1 us) */
123 * zyfer_start - open the devices and initialize data for processing
141 fd = refclock_open(&peer->srcadr, device, SPEED232, LDISC_RAW);
152 pp = peer->procptr;
153 pp->io.clock_recv = zyfer_receive;
154 pp->io.srcclock = peer;
155 pp->io.datalen = 0;
156 pp->io.fd = fd;
157 if (!io_addclock(&pp->io)) {
159 pp->io.fd = -1;
160 free(up);
163 pp->unitptr = up;
168 peer->precision = PRECISION;
169 pp->clockdesc = DESCRIPTION;
170 memcpy((char *)&pp->refid, REFID, 4);
171 up->pollcnt = 2;
172 up->polled = 0; /* May not be needed... */
179 * zyfer_shutdown - shut down the clock
190 pp = peer->procptr;
191 up = pp->unitptr;
192 if (pp->io.fd != -1)
193 io_closeclock(&pp->io);
195 free(up);
200 * zyfer_receive - receive data from the serial interface
219 peer = rbufp->recv_peer;
220 pp = peer->procptr;
221 up = pp->unitptr;
222 p = (u_char *) &rbufp->recv_space;
225 * - if *rbufp->recv_space is !
226 * - - call refclock_gtlin to get things going
227 * - else flush
230 * - wait for more data
235 * Under FreeBSD, we get the ! followed by two 14-byte packets.
238 if (pp->lencode >= LENZYFER)
239 pp->lencode = 0;
241 if (!pp->lencode) {
243 pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode,
244 BMAX, &pp->lastrec);
248 memcpy(pp->a_lastcode + pp->lencode, p, rbufp->recv_length);
249 pp->lencode += rbufp->recv_length;
250 pp->a_lastcode[pp->lencode] = '\0';
253 if (pp->lencode < LENZYFER)
256 record_clock_stats(&peer->srcadr, pp->a_lastcode);
264 if (pp->lencode != LENZYFER) {
272 if (sscanf(pp->a_lastcode, "!TIME,%4d,%3d,%2d,%2d,%2d,%d,%d,%d",
273 &pp->year, &pp->day, &pp->hour, &pp->minute, &pp->second,
287 pp->leap = LEAP_NOTINSYNC;
295 tsdoy.year = pp->year;
296 tsdoy.yearday = pp->day;
297 tsdoy.hour = pp->hour;
298 tsdoy.minute = pp->minute;
299 tsdoy.second = pp->second;
302 * day-of-year based calculation now:
306 refclock_process_offset(pp, tfrac, pp->lastrec, pp->fudgetime1);
311 up->pollcnt = 2;
313 if (up->polled) {
314 up->polled = 0;
321 * zyfer_poll - called by the transmit procedure
336 pp = peer->procptr;
337 up = pp->unitptr;
338 if (!up->pollcnt)
341 up->pollcnt--;
342 pp->polls++;
343 up->polled = 1;