Lines Matching +full:up +full:- +full:to

2  * refclock_chronolog - clock driver for Chronolog K-series WWVB receiver.
6 * Must interpolate back to local time. Very annoying.
26 * This driver supports the Chronolog K-series WWVB receiver.
33 * YY/MM/DD -- what you'd expect. This arrives a few seconds before the
35 * hh:mm:ss -- what you'd expect. We take time on the <cr>.
38 * otherwise. The clock seems to appear every 60 seconds, which doesn't make
49 #define PRECISION (-13) /* precision assumed (about 100 us) */
51 #define DESCRIPTION "Chrono-log K" /* WRU */
56 * Chrono-log unit control structure
62 int year; /* Y2K-adjusted year */
63 int day; /* day-of-month */
64 int month; /* month-of-year */
79 chronolog_start, /* start up driver */
81 chronolog_poll, /* poll the driver -- a nice fabrication */
90 * chronolog_start - open the devices and initialize data for processing
98 register struct chronolog_unit *up; in chronolog_start() local
112 fd = refclock_open(&peer->srcadr, device, SPEED232, 0); in chronolog_start()
119 up = emalloc_zero(sizeof(*up)); in chronolog_start()
120 pp = peer->procptr; in chronolog_start()
121 pp->unitptr = up; in chronolog_start()
122 pp->io.clock_recv = chronolog_receive; in chronolog_start()
123 pp->io.srcclock = peer; in chronolog_start()
124 pp->io.datalen = 0; in chronolog_start()
125 pp->io.fd = fd; in chronolog_start()
126 if (!io_addclock(&pp->io)) { in chronolog_start()
128 pp->io.fd = -1; in chronolog_start()
129 free(up); in chronolog_start()
130 pp->unitptr = NULL; in chronolog_start()
137 peer->precision = PRECISION; in chronolog_start()
138 pp->clockdesc = DESCRIPTION; in chronolog_start()
139 memcpy((char *)&pp->refid, REFID, 4); in chronolog_start()
145 * chronolog_shutdown - shut down the clock
153 register struct chronolog_unit *up; in chronolog_shutdown() local
156 pp = peer->procptr; in chronolog_shutdown()
157 up = pp->unitptr; in chronolog_shutdown()
158 if (-1 != pp->io.fd) in chronolog_shutdown()
159 io_closeclock(&pp->io); in chronolog_shutdown()
160 if (NULL != up) in chronolog_shutdown()
161 free(up); in chronolog_shutdown()
166 * chronolog_receive - receive data from the serial interface
173 struct chronolog_unit *up; in chronolog_receive() local
178 int hours; /* hour-of-day */ in chronolog_receive()
179 int minutes; /* minutes-past-the-hour */ in chronolog_receive()
187 peer = rbufp->recv_peer; in chronolog_receive()
188 pp = peer->procptr; in chronolog_receive()
189 up = pp->unitptr; in chronolog_receive()
190 temp = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp); in chronolog_receive()
193 if (up->tcswitch == 0) { in chronolog_receive()
194 up->tcswitch = 1; in chronolog_receive()
195 up->laststamp = trtmp; in chronolog_receive()
197 up->tcswitch = 0; in chronolog_receive()
200 pp->lencode = temp; in chronolog_receive()
201 pp->lastrec = up->laststamp; in chronolog_receive()
202 up->laststamp = trtmp; in chronolog_receive()
203 up->tcswitch = 1; in chronolog_receive()
207 printf("chronolog: timecode %d %s\n", pp->lencode, in chronolog_receive()
208 pp->a_lastcode); in chronolog_receive()
212 * We get down to business. Check the timecode format and decode in chronolog_receive()
213 * its contents. This code uses the first character to see whether in chronolog_receive()
219 if (sscanf(pp->a_lastcode, "Y %d/%d/%d", &up->year,&up->month,&up->day)) in chronolog_receive()
222 * Y2K convert the 2-digit year in chronolog_receive()
224 up->year = up->year >= 69 ? up->year : up->year + 100; in chronolog_receive()
227 if (sscanf(pp->a_lastcode,"Z %02d:%02d:%02d", in chronolog_receive()
238 * Convert to GMT for sites that distribute localtime. This in chronolog_receive()
239 * means we have to do Y2K conversion on the 2-digit year; in chronolog_receive()
245 local.tm_year = up->year; in chronolog_receive()
246 local.tm_mon = up->month-1; in chronolog_receive()
247 local.tm_mday = up->day; in chronolog_receive()
251 local.tm_isdst = -1; in chronolog_receive()
259 adjyear = gmtp->tm_year+1900; in chronolog_receive()
260 adjmon = gmtp->tm_mon+1; in chronolog_receive()
261 pp->day = ymd2yd (adjyear, adjmon, gmtp->tm_mday); in chronolog_receive()
262 pp->hour = gmtp->tm_hour; in chronolog_receive()
263 pp->minute = gmtp->tm_min; in chronolog_receive()
264 pp->second = gmtp->tm_sec; in chronolog_receive()
268 adjyear,adjmon,gmtp->tm_mday,pp->hour,pp->minute, in chronolog_receive()
269 pp->second); in chronolog_receive()
276 pp->day = ymd2yd(year+1900,month,day); in chronolog_receive()
277 pp->hour = hours; in chronolog_receive()
278 pp->minute = minutes; in chronolog_receive()
279 pp->second = seconds; in chronolog_receive()
297 pp->lastref = pp->lastrec; in chronolog_receive()
299 record_clock_stats(&peer->srcadr, pp->a_lastcode); in chronolog_receive()
300 up->lasthour = (u_char)pp->hour; in chronolog_receive()
305 * chronolog_poll - called by the transmit procedure
314 * Time to poll the clock. The Chrono-log clock is supposed to in chronolog_poll()
315 * respond to a 'T' by returning a timecode in the format(s) in chronolog_poll()
316 * specified above. Ours does (can?) not, but this seems to be in chronolog_poll()
317 * an installation-specific problem. This code is dyked out, in chronolog_poll()
318 * but may be re-enabled if anyone ever finds a Chrono-log that in chronolog_poll()
319 * actually listens to this command. in chronolog_poll()
322 register struct chronolog_unit *up; in chronolog_poll()
326 pp = peer->procptr; in chronolog_poll()
327 up = pp->unitptr; in chronolog_poll()
328 if (peer->burst == 0 && peer->reach == 0) in chronolog_poll()
330 if (up->linect > 0) in chronolog_poll()
334 if (write(pp->io.fd, &pollchar, 1) != 1) in chronolog_poll()
337 pp->polls++; in chronolog_poll()