Deleted Added
full compact
refclock_wwvb.c (82498) refclock_wwvb.c (132451)
1/*
2 * refclock_wwvb - clock driver for Spectracom WWVB receivers
3 */
4
5#ifdef HAVE_CONFIG_H
6#include <config.h>
7#endif
8

--- 89 unchanged lines hidden (view full) ---

98 */
99#define DEVICE "/dev/wwvb%d" /* device name and unit */
100#define SPEED232 B9600 /* uart speed (9600 baud) */
101#define PRECISION (-13) /* precision assumed (about 100 us) */
102#define REFID "WWVB" /* reference ID */
103#define DESCRIPTION "Spectracom WWVB/GPS Receivers" /* WRU */
104
105#define LENWWVB0 22 /* format 0 timecode length */
1/*
2 * refclock_wwvb - clock driver for Spectracom WWVB receivers
3 */
4
5#ifdef HAVE_CONFIG_H
6#include <config.h>
7#endif
8

--- 89 unchanged lines hidden (view full) ---

98 */
99#define DEVICE "/dev/wwvb%d" /* device name and unit */
100#define SPEED232 B9600 /* uart speed (9600 baud) */
101#define PRECISION (-13) /* precision assumed (about 100 us) */
102#define REFID "WWVB" /* reference ID */
103#define DESCRIPTION "Spectracom WWVB/GPS Receivers" /* WRU */
104
105#define LENWWVB0 22 /* format 0 timecode length */
106#define LENWWVB1 22 /* format 1 timecode length */
106#define LENWWVB2 24 /* format 2 timecode length */
107#define LENWWVB3 29 /* format 3 timecode length */
108#define MONLIN 15 /* number of monitoring lines */
109
110/*
111 * WWVB unit control structure
112 */
113struct wwvbunit {

--- 68 unchanged lines hidden (view full) ---

182 }
183
184 /*
185 * Initialize miscellaneous variables
186 */
187 peer->precision = PRECISION;
188 pp->clockdesc = DESCRIPTION;
189 memcpy((char *)&pp->refid, REFID, 4);
107#define LENWWVB2 24 /* format 2 timecode length */
108#define LENWWVB3 29 /* format 3 timecode length */
109#define MONLIN 15 /* number of monitoring lines */
110
111/*
112 * WWVB unit control structure
113 */
114struct wwvbunit {

--- 68 unchanged lines hidden (view full) ---

183 }
184
185 /*
186 * Initialize miscellaneous variables
187 */
188 peer->precision = PRECISION;
189 pp->clockdesc = DESCRIPTION;
190 memcpy((char *)&pp->refid, REFID, 4);
190 peer->burst = NSTAGE;
191 peer->burst = MAXSTAGE;
191 return (1);
192}
193
194
195/*
196 * wwvb_shutdown - shut down the clock
197 */
198static void

--- 59 unchanged lines hidden (view full) ---

258 } else
259 up->tcswitch = 0;
260 return;
261 }
262 pp->lencode = temp;
263 pp->lastrec = up->laststamp;
264 up->laststamp = trtmp;
265 up->tcswitch = 1;
192 return (1);
193}
194
195
196/*
197 * wwvb_shutdown - shut down the clock
198 */
199static void

--- 59 unchanged lines hidden (view full) ---

259 } else
260 up->tcswitch = 0;
261 return;
262 }
263 pp->lencode = temp;
264 pp->lastrec = up->laststamp;
265 up->laststamp = trtmp;
266 up->tcswitch = 1;
266#ifdef DEBUG
267 if (debug)
268 printf("wwvb: timecode %d %s\n", pp->lencode,
269 pp->a_lastcode);
270#endif
271
272 /*
273 * We get down to business, check the timecode format and decode
274 * its contents. This code uses the timecode length to determine
275 * format 0, 2 or 3. If the timecode has invalid length or is
276 * not in proper format, we declare bad format and exit.
277 */
278 syncchar = qualchar = leapchar = dstchar = ' ';
279 tz = 0;
267
268 /*
269 * We get down to business, check the timecode format and decode
270 * its contents. This code uses the timecode length to determine
271 * format 0, 2 or 3. If the timecode has invalid length or is
272 * not in proper format, we declare bad format and exit.
273 */
274 syncchar = qualchar = leapchar = dstchar = ' ';
275 tz = 0;
280 pp->msec = 0;
281 switch (pp->lencode) {
282
276 switch (pp->lencode) {
277
283 case LENWWVB0:
278 case LENWWVB0:
284
285 /*
286 * Timecode format 0: "I ddd hh:mm:ss DTZ=nn"
287 */
288 if (sscanf(pp->a_lastcode,
289 "%c %3d %2d:%2d:%2d%c%cTZ=%2d",
290 &syncchar, &pp->day, &pp->hour, &pp->minute,
291 &pp->second, &tmpchar, &dstchar, &tz) == 8)
279
280 /*
281 * Timecode format 0: "I ddd hh:mm:ss DTZ=nn"
282 */
283 if (sscanf(pp->a_lastcode,
284 "%c %3d %2d:%2d:%2d%c%cTZ=%2d",
285 &syncchar, &pp->day, &pp->hour, &pp->minute,
286 &pp->second, &tmpchar, &dstchar, &tz) == 8)
287 pp->nsec = 0;
292 break;
293
288 break;
289
294 case LENWWVB2:
290 case LENWWVB2:
295
296 /*
297 * Timecode format 2: "IQyy ddd hh:mm:ss.mmm LD" */
298 if (sscanf(pp->a_lastcode,
291
292 /*
293 * Timecode format 2: "IQyy ddd hh:mm:ss.mmm LD" */
294 if (sscanf(pp->a_lastcode,
299 "%c%c %2d %3d %2d:%2d:%2d.%3d %c",
295 "%c%c %2d %3d %2d:%2d:%2d.%3ld %c",
300 &syncchar, &qualchar, &pp->year, &pp->day,
296 &syncchar, &qualchar, &pp->year, &pp->day,
301 &pp->hour, &pp->minute, &pp->second, &pp->msec,
297 &pp->hour, &pp->minute, &pp->second, &pp->nsec,
302 &leapchar) == 9)
298 &leapchar) == 9)
299 pp->nsec *= 1000000;
303 break;
304
300 break;
301
305 case LENWWVB3:
302 case LENWWVB3:
306
307 /*
308 * Timecode format 3: "0003I yyyymmdd hhmmss+0000SL#"
309 */
310 if (sscanf(pp->a_lastcode,
311 "0003%c %4d%2d%2d %2d%2d%2d+0000%c%c",
312 &syncchar, &pp->year, &month, &day, &pp->hour,
313 &pp->minute, &pp->second, &dstchar, &leapchar) == 8)
314 {
315 pp->day = ymd2yd(pp->year, month, day);
303
304 /*
305 * Timecode format 3: "0003I yyyymmdd hhmmss+0000SL#"
306 */
307 if (sscanf(pp->a_lastcode,
308 "0003%c %4d%2d%2d %2d%2d%2d+0000%c%c",
309 &syncchar, &pp->year, &month, &day, &pp->hour,
310 &pp->minute, &pp->second, &dstchar, &leapchar) == 8)
311 {
312 pp->day = ymd2yd(pp->year, month, day);
313 pp->nsec = 0;
316 break;
317 }
318
314 break;
315 }
316
319 default:
317 default:
320
321 /*
322 * Unknown format: If dumping internal table, record
323 * stats; otherwise, declare bad format.
324 */
325 if (up->linect > 0) {
326 up->linect--;
327 record_clock_stats(&peer->srcadr,

--- 10 unchanged lines hidden (view full) ---

338 * Otherwise, set the leap bits according to the leap character.
339 * Once synchronized, the dispersion depends only on the
340 * quality character.
341 */
342 switch (qualchar) {
343
344 case ' ':
345 pp->disp = .001;
318
319 /*
320 * Unknown format: If dumping internal table, record
321 * stats; otherwise, declare bad format.
322 */
323 if (up->linect > 0) {
324 up->linect--;
325 record_clock_stats(&peer->srcadr,

--- 10 unchanged lines hidden (view full) ---

336 * Otherwise, set the leap bits according to the leap character.
337 * Once synchronized, the dispersion depends only on the
338 * quality character.
339 */
340 switch (qualchar) {
341
342 case ' ':
343 pp->disp = .001;
344 pp->lastref = pp->lastrec;
346 break;
347
348 case 'A':
349 pp->disp = .01;
350 break;
351
352 case 'B':
353 pp->disp = .1;

--- 52 unchanged lines hidden (view full) ---

406 pp = peer->procptr;
407 up = (struct wwvbunit *)pp->unitptr;
408 if (up->linect > 0)
409 pollchar = 'R';
410 else
411 pollchar = 'T';
412 if (write(pp->io.fd, &pollchar, 1) != 1)
413 refclock_report(peer, CEVNT_FAULT);
345 break;
346
347 case 'A':
348 pp->disp = .01;
349 break;
350
351 case 'B':
352 pp->disp = .1;

--- 52 unchanged lines hidden (view full) ---

405 pp = peer->procptr;
406 up = (struct wwvbunit *)pp->unitptr;
407 if (up->linect > 0)
408 pollchar = 'R';
409 else
410 pollchar = 'T';
411 if (write(pp->io.fd, &pollchar, 1) != 1)
412 refclock_report(peer, CEVNT_FAULT);
414 else
415 pp->polls++;
416 if (peer->burst > 0)
417 return;
418 if (pp->coderecv == pp->codeproc) {
419 refclock_report(peer, CEVNT_TIMEOUT);
420 return;
421 }
413 if (peer->burst > 0)
414 return;
415 if (pp->coderecv == pp->codeproc) {
416 refclock_report(peer, CEVNT_TIMEOUT);
417 return;
418 }
422 record_clock_stats(&peer->srcadr, pp->a_lastcode);
423 refclock_receive(peer);
419 refclock_receive(peer);
424 peer->burst = NSTAGE;
420 record_clock_stats(&peer->srcadr, pp->a_lastcode);
421#ifdef DEBUG
422 if (debug)
423 printf("wwvb: timecode %d %s\n", pp->lencode,
424 pp->a_lastcode);
425#endif
426 peer->burst = MAXSTAGE;
427 pp->polls++;
425
426 /*
427 * If the monitor flag is set (flag4), we dump the internal
428 * quality table at the first timecode beginning the day.
429 */
430 if (pp->sloppyclockflag & CLK_FLAG4 && pp->hour <
431 (int)up->lasthour)
432 up->linect = MONLIN;
433 up->lasthour = pp->hour;
434}
435
436#else
437int refclock_wwvb_bs;
438#endif /* REFCLOCK */
428
429 /*
430 * If the monitor flag is set (flag4), we dump the internal
431 * quality table at the first timecode beginning the day.
432 */
433 if (pp->sloppyclockflag & CLK_FLAG4 && pp->hour <
434 (int)up->lasthour)
435 up->linect = MONLIN;
436 up->lasthour = pp->hour;
437}
438
439#else
440int refclock_wwvb_bs;
441#endif /* REFCLOCK */