154359Sroberto/*
2182007Sroberto * /src/NTP/ntp4-dev/parseutil/testdcf.c,v 4.10 2005/08/06 14:18:43 kardel RELEASE_20050806_A
3182007Sroberto *
4182007Sroberto * testdcf.c,v 4.10 2005/08/06 14:18:43 kardel RELEASE_20050806_A
554359Sroberto *
654359Sroberto * simple DCF77 100/200ms pulse test program (via 50Baud serial line)
754359Sroberto *
8182007Sroberto * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
9182007Sroberto * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universit�t Erlangen-N�rnberg, Germany
1054359Sroberto *
11182007Sroberto * Redistribution and use in source and binary forms, with or without
12182007Sroberto * modification, are permitted provided that the following conditions
13182007Sroberto * are met:
14182007Sroberto * 1. Redistributions of source code must retain the above copyright
15182007Sroberto *    notice, this list of conditions and the following disclaimer.
16182007Sroberto * 2. Redistributions in binary form must reproduce the above copyright
17182007Sroberto *    notice, this list of conditions and the following disclaimer in the
18182007Sroberto *    documentation and/or other materials provided with the distribution.
19182007Sroberto * 3. Neither the name of the author nor the names of its contributors
20182007Sroberto *    may be used to endorse or promote products derived from this software
21182007Sroberto *    without specific prior written permission.
22182007Sroberto *
23182007Sroberto * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24182007Sroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25182007Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26182007Sroberto * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27182007Sroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28182007Sroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29182007Sroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30182007Sroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31182007Sroberto * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32182007Sroberto * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33182007Sroberto * SUCH DAMAGE.
34182007Sroberto *
3554359Sroberto */
3654359Sroberto
3782498Sroberto#include "ntp_stdlib.h"
3882498Sroberto
39182007Sroberto#include <sys/ioctl.h>
4054359Sroberto#include <unistd.h>
4154359Sroberto#include <stdio.h>
4254359Sroberto#include <fcntl.h>
4354359Sroberto#include <termios.h>
4454359Sroberto
4554359Sroberto/*
4654359Sroberto * state flags
4754359Sroberto */
4854359Sroberto#define DCFB_ANNOUNCE           0x0001 /* switch time zone warning (DST switch) */
4954359Sroberto#define DCFB_DST                0x0002 /* DST in effect */
50132451Sroberto#define DCFB_LEAP		0x0004 /* LEAP warning (1 hour prior to occurrence) */
5154359Sroberto#define DCFB_ALTERNATE		0x0008 /* alternate antenna used */
5254359Sroberto
5354359Srobertostruct clocktime		/* clock time broken up from time code */
5454359Sroberto{
5554359Sroberto	long wday;
5654359Sroberto	long day;
5754359Sroberto	long month;
5854359Sroberto	long year;
5954359Sroberto	long hour;
6054359Sroberto	long minute;
6154359Sroberto	long second;
6254359Sroberto	long usecond;
6354359Sroberto	long utcoffset;	/* in minutes */
6454359Sroberto	long flags;		/* current clock status */
6554359Sroberto};
6654359Sroberto
6754359Srobertotypedef struct clocktime clocktime_t;
6854359Sroberto
69182007Srobertostatic char type(unsigned int);
70182007Sroberto
7154359Sroberto#define TIMES10(_X_) (((_X_) << 3) + ((_X_) << 1))
7254359Sroberto
7354359Sroberto/*
7454359Sroberto * parser related return/error codes
7554359Sroberto */
7654359Sroberto#define CVT_MASK	0x0000000F /* conversion exit code */
7754359Sroberto#define   CVT_NONE	0x00000001 /* format not applicable */
7854359Sroberto#define   CVT_FAIL	0x00000002 /* conversion failed - error code returned */
7954359Sroberto#define   CVT_OK	0x00000004 /* conversion succeeded */
8054359Sroberto#define CVT_BADFMT	0x00000010 /* general format error - (unparsable) */
8154359Sroberto
8254359Sroberto/*
8354359Sroberto * DCF77 raw time code
8454359Sroberto *
8554359Sroberto * From "Zur Zeit", Physikalisch-Technische Bundesanstalt (PTB), Braunschweig
8654359Sroberto * und Berlin, Maerz 1989
8754359Sroberto *
8854359Sroberto * Timecode transmission:
8954359Sroberto * AM:
9054359Sroberto *	time marks are send every second except for the second before the
9154359Sroberto *	next minute mark
9254359Sroberto *	time marks consist of a reduction of transmitter power to 25%
9354359Sroberto *	of the nominal level
9454359Sroberto *	the falling edge is the time indication (on time)
9554359Sroberto *	time marks of a 100ms duration constitute a logical 0
9654359Sroberto *	time marks of a 200ms duration constitute a logical 1
9754359Sroberto * FM:
9854359Sroberto *	see the spec. (basically a (non-)inverted psuedo random phase shift)
9954359Sroberto *
10054359Sroberto * Encoding:
10154359Sroberto * Second	Contents
10254359Sroberto * 0  - 10	AM: free, FM: 0
10354359Sroberto * 11 - 14	free
10454359Sroberto * 15		R     - alternate antenna
10554359Sroberto * 16		A1    - expect zone change (1 hour before)
10654359Sroberto * 17 - 18	Z1,Z2 - time zone
10754359Sroberto *		 0  0 illegal
10854359Sroberto *		 0  1 MEZ  (MET)
10954359Sroberto *		 1  0 MESZ (MED, MET DST)
11054359Sroberto *		 1  1 illegal
11154359Sroberto * 19		A2    - expect leap insertion/deletion (1 hour before)
11254359Sroberto * 20		S     - start of time code (1)
11354359Sroberto * 21 - 24	M1    - BCD (lsb first) Minutes
11454359Sroberto * 25 - 27	M10   - BCD (lsb first) 10 Minutes
11554359Sroberto * 28		P1    - Minute Parity (even)
11654359Sroberto * 29 - 32	H1    - BCD (lsb first) Hours
11754359Sroberto * 33 - 34      H10   - BCD (lsb first) 10 Hours
11854359Sroberto * 35		P2    - Hour Parity (even)
11954359Sroberto * 36 - 39	D1    - BCD (lsb first) Days
12054359Sroberto * 40 - 41	D10   - BCD (lsb first) 10 Days
12154359Sroberto * 42 - 44	DW    - BCD (lsb first) day of week (1: Monday -> 7: Sunday)
12254359Sroberto * 45 - 49	MO    - BCD (lsb first) Month
12354359Sroberto * 50           MO0   - 10 Months
12454359Sroberto * 51 - 53	Y1    - BCD (lsb first) Years
12554359Sroberto * 54 - 57	Y10   - BCD (lsb first) 10 Years
12654359Sroberto * 58 		P3    - Date Parity (even)
12754359Sroberto * 59		      - usually missing (minute indication), except for leap insertion
12854359Sroberto */
12954359Sroberto
130182007Srobertostatic char revision[] = "4.10";
131182007Sroberto
13254359Srobertostatic struct rawdcfcode
13354359Sroberto{
13454359Sroberto	char offset;			/* start bit */
13554359Sroberto} rawdcfcode[] =
13654359Sroberto{
13754359Sroberto	{  0 }, { 15 }, { 16 }, { 17 }, { 19 }, { 20 }, { 21 }, { 25 }, { 28 }, { 29 },
13854359Sroberto	{ 33 }, { 35 }, { 36 }, { 40 }, { 42 }, { 45 }, { 49 }, { 50 }, { 54 }, { 58 }, { 59 }
13954359Sroberto};
14054359Sroberto
14154359Sroberto#define DCF_M	0
14254359Sroberto#define DCF_R	1
14354359Sroberto#define DCF_A1	2
14454359Sroberto#define DCF_Z	3
14554359Sroberto#define DCF_A2	4
14654359Sroberto#define DCF_S	5
14754359Sroberto#define DCF_M1	6
14854359Sroberto#define DCF_M10	7
14954359Sroberto#define DCF_P1	8
15054359Sroberto#define DCF_H1	9
15154359Sroberto#define DCF_H10	10
15254359Sroberto#define DCF_P2	11
15354359Sroberto#define DCF_D1	12
15454359Sroberto#define DCF_D10	13
15554359Sroberto#define DCF_DW	14
15654359Sroberto#define DCF_MO	15
15754359Sroberto#define DCF_MO0	16
15854359Sroberto#define DCF_Y1	17
15954359Sroberto#define DCF_Y10	18
16054359Sroberto#define DCF_P3	19
16154359Sroberto
16254359Srobertostatic struct partab
16354359Sroberto{
16454359Sroberto	char offset;			/* start bit of parity field */
16554359Sroberto} partab[] =
16654359Sroberto{
16754359Sroberto	{ 21 }, { 29 }, { 36 }, { 59 }
16854359Sroberto};
16954359Sroberto
17054359Sroberto#define DCF_P_P1	0
17154359Sroberto#define DCF_P_P2	1
17254359Sroberto#define DCF_P_P3	2
17354359Sroberto
17454359Sroberto#define DCF_Z_MET 0x2
17554359Sroberto#define DCF_Z_MED 0x1
17654359Sroberto
17754359Srobertostatic unsigned long
17854359Srobertoext_bf(
17954359Sroberto	register unsigned char *buf,
18054359Sroberto	register int   idx
18154359Sroberto	)
18254359Sroberto{
18354359Sroberto	register unsigned long sum = 0;
18454359Sroberto	register int i, first;
18554359Sroberto
18654359Sroberto	first = rawdcfcode[idx].offset;
18754359Sroberto
18854359Sroberto	for (i = rawdcfcode[idx+1].offset - 1; i >= first; i--)
18954359Sroberto	{
19054359Sroberto		sum <<= 1;
19154359Sroberto		sum |= (buf[i] != '-');
19254359Sroberto	}
19354359Sroberto	return sum;
19454359Sroberto}
19554359Sroberto
19654359Srobertostatic unsigned
19754359Srobertopcheck(
19854359Sroberto	register unsigned char *buf,
19954359Sroberto	register int   idx
20054359Sroberto	)
20154359Sroberto{
20254359Sroberto	register int i,last;
20354359Sroberto	register unsigned psum = 1;
20454359Sroberto
20554359Sroberto	last = partab[idx+1].offset;
20654359Sroberto
20754359Sroberto	for (i = partab[idx].offset; i < last; i++)
20854359Sroberto	    psum ^= (buf[i] != '-');
20954359Sroberto
21054359Sroberto	return psum;
21154359Sroberto}
21254359Sroberto
21354359Srobertostatic unsigned long
21454359Srobertoconvert_rawdcf(
21554359Sroberto	register unsigned char   *buffer,
21654359Sroberto	register int              size,
21754359Sroberto	register clocktime_t     *clock_time
21854359Sroberto	)
21954359Sroberto{
22054359Sroberto	if (size < 57)
22154359Sroberto	{
22254359Sroberto		printf("%-30s", "*** INCOMPLETE");
22354359Sroberto		return CVT_NONE;
22454359Sroberto	}
22554359Sroberto
22654359Sroberto	/*
22754359Sroberto	 * check Start and Parity bits
22854359Sroberto	 */
22954359Sroberto	if ((ext_bf(buffer, DCF_S) == 1) &&
23054359Sroberto	    pcheck(buffer, DCF_P_P1) &&
23154359Sroberto	    pcheck(buffer, DCF_P_P2) &&
23254359Sroberto	    pcheck(buffer, DCF_P_P3))
23354359Sroberto	{
23454359Sroberto		/*
23554359Sroberto		 * buffer OK
23654359Sroberto		 */
23754359Sroberto
23854359Sroberto		clock_time->flags  = 0;
23954359Sroberto		clock_time->usecond= 0;
24054359Sroberto		clock_time->second = 0;
24154359Sroberto		clock_time->minute = ext_bf(buffer, DCF_M10);
24254359Sroberto		clock_time->minute = TIMES10(clock_time->minute) + ext_bf(buffer, DCF_M1);
24354359Sroberto		clock_time->hour   = ext_bf(buffer, DCF_H10);
24454359Sroberto		clock_time->hour   = TIMES10(clock_time->hour) + ext_bf(buffer, DCF_H1);
24554359Sroberto		clock_time->day    = ext_bf(buffer, DCF_D10);
24654359Sroberto		clock_time->day    = TIMES10(clock_time->day) + ext_bf(buffer, DCF_D1);
24754359Sroberto		clock_time->month  = ext_bf(buffer, DCF_MO0);
24854359Sroberto		clock_time->month  = TIMES10(clock_time->month) + ext_bf(buffer, DCF_MO);
24954359Sroberto		clock_time->year   = ext_bf(buffer, DCF_Y10);
25054359Sroberto		clock_time->year   = TIMES10(clock_time->year) + ext_bf(buffer, DCF_Y1);
25154359Sroberto		clock_time->wday   = ext_bf(buffer, DCF_DW);
25254359Sroberto
25354359Sroberto		switch (ext_bf(buffer, DCF_Z))
25454359Sroberto		{
25554359Sroberto		    case DCF_Z_MET:
25654359Sroberto			clock_time->utcoffset = -60;
25754359Sroberto			break;
25854359Sroberto
25954359Sroberto		    case DCF_Z_MED:
26054359Sroberto			clock_time->flags     |= DCFB_DST;
26154359Sroberto			clock_time->utcoffset  = -120;
26254359Sroberto			break;
26354359Sroberto
26454359Sroberto		    default:
26554359Sroberto			printf("%-30s", "*** BAD TIME ZONE");
26654359Sroberto			return CVT_FAIL|CVT_BADFMT;
26754359Sroberto		}
26854359Sroberto
26954359Sroberto		if (ext_bf(buffer, DCF_A1))
27054359Sroberto		    clock_time->flags |= DCFB_ANNOUNCE;
27154359Sroberto
27254359Sroberto		if (ext_bf(buffer, DCF_A2))
27354359Sroberto		    clock_time->flags |= DCFB_LEAP;
27454359Sroberto
27554359Sroberto		if (ext_bf(buffer, DCF_R))
27654359Sroberto		    clock_time->flags |= DCFB_ALTERNATE;
27754359Sroberto
27854359Sroberto		return CVT_OK;
27954359Sroberto	}
28054359Sroberto	else
28154359Sroberto	{
28254359Sroberto		/*
28354359Sroberto		 * bad format - not for us
28454359Sroberto		 */
28554359Sroberto		printf("%-30s", "*** BAD FORMAT (invalid/parity)");
28654359Sroberto		return CVT_FAIL|CVT_BADFMT;
28754359Sroberto	}
28854359Sroberto}
28954359Sroberto
290182007Srobertostatic char
29154359Srobertotype(
29254359Sroberto	unsigned int c
29354359Sroberto	)
29454359Sroberto{
29554359Sroberto	c ^= 0xFF;
296182007Sroberto	return (c >= 0xF);
29754359Sroberto}
29854359Sroberto
29954359Srobertostatic const char *wday[8] =
30054359Sroberto{
30154359Sroberto	"??",
30254359Sroberto	"Mo",
30354359Sroberto	"Tu",
30454359Sroberto	"We",
30554359Sroberto	"Th",
30654359Sroberto	"Fr",
30754359Sroberto	"Sa",
30854359Sroberto	"Su"
30954359Sroberto};
31054359Sroberto
31154359Srobertostatic char pat[] = "-\\|/";
31254359Sroberto
31354359Sroberto#define LINES (24-2)	/* error lines after which the two headlines are repeated */
31454359Sroberto
31554359Srobertoint
31654359Srobertomain(
31754359Sroberto	int argc,
31854359Sroberto	char *argv[]
31954359Sroberto	)
32054359Sroberto{
32154359Sroberto	if ((argc != 2) && (argc != 3))
32254359Sroberto	{
32354359Sroberto		fprintf(stderr, "usage: %s [-f|-t|-ft|-tf] <device>\n", argv[0]);
32454359Sroberto		exit(1);
32554359Sroberto	}
32654359Sroberto	else
32754359Sroberto	{
32854359Sroberto		unsigned char c;
32954359Sroberto		char *file;
33054359Sroberto		int fd;
33154359Sroberto		int offset = 15;
33254359Sroberto		int trace = 0;
33354359Sroberto		int errs = LINES+1;
33454359Sroberto
33554359Sroberto		/*
33654359Sroberto		 * SIMPLE(!) argument "parser"
33754359Sroberto		 */
33854359Sroberto		if (argc == 3)
33954359Sroberto		{
34054359Sroberto			if (strcmp(argv[1], "-f") == 0)
34154359Sroberto			    offset = 0;
34254359Sroberto			if (strcmp(argv[1], "-t") == 0)
34354359Sroberto			    trace = 1;
34454359Sroberto			if ((strcmp(argv[1], "-ft") == 0) ||
34554359Sroberto			    (strcmp(argv[1], "-tf") == 0))
34654359Sroberto			{
34754359Sroberto				offset = 0;
34854359Sroberto				trace = 1;
34954359Sroberto			}
35054359Sroberto			file = argv[2];
35154359Sroberto		}
35254359Sroberto		else
35354359Sroberto		{
35454359Sroberto			file = argv[1];
35554359Sroberto		}
35654359Sroberto
35754359Sroberto		fd = open(file, O_RDONLY);
35854359Sroberto		if (fd == -1)
35954359Sroberto		{
36054359Sroberto			perror(file);
36154359Sroberto			exit(1);
36254359Sroberto		}
36354359Sroberto		else
36454359Sroberto		{
36554359Sroberto			int i;
36654359Sroberto#ifdef TIOCM_RTS
36754359Sroberto			int on = TIOCM_RTS;
36854359Sroberto#endif
36954359Sroberto			struct timeval t, tt, tlast;
37054359Sroberto			char buf[61];
37154359Sroberto			clocktime_t clock_time;
37254359Sroberto			struct termios term;
37354359Sroberto			int rtc = CVT_NONE;
37454359Sroberto
37554359Sroberto			if (tcgetattr(fd,  &term) == -1)
37654359Sroberto			{
37754359Sroberto				perror("tcgetattr");
37854359Sroberto				exit(1);
37954359Sroberto			}
38054359Sroberto
38154359Sroberto			memset(term.c_cc, 0, sizeof(term.c_cc));
38254359Sroberto			term.c_cc[VMIN] = 1;
38354359Sroberto#ifdef NO_PARENB_IGNPAR /* Was: defined(SYS_IRIX4) || defined (SYS_IRIX5) */
38454359Sroberto			/* somehow doesn't grok PARENB & IGNPAR (mj) */
385182007Sroberto			term.c_cflag = CS8|CREAD|CLOCAL;
38654359Sroberto#else
387182007Sroberto			term.c_cflag = CS8|CREAD|CLOCAL|PARENB;
38854359Sroberto#endif
38954359Sroberto			term.c_iflag = IGNPAR;
39054359Sroberto			term.c_oflag = 0;
39154359Sroberto			term.c_lflag = 0;
39254359Sroberto
393182007Sroberto			cfsetispeed(&term, B50);
394182007Sroberto			cfsetospeed(&term, B50);
395182007Sroberto
39654359Sroberto			if (tcsetattr(fd, TCSANOW, &term) == -1)
39754359Sroberto			{
39854359Sroberto				perror("tcsetattr");
39954359Sroberto				exit(1);
40054359Sroberto			}
40154359Sroberto
40254359Sroberto#ifdef I_POP
40354359Sroberto			while (ioctl(fd, I_POP, 0) == 0)
40454359Sroberto			    ;
40554359Sroberto#endif
40654359Sroberto#if defined(TIOCMBIC) && defined(TIOCM_RTS)
40754359Sroberto			if (ioctl(fd, TIOCMBIC, (caddr_t)&on) == -1)
40854359Sroberto			{
40954359Sroberto				perror("TIOCM_RTS");
41054359Sroberto			}
41154359Sroberto#endif
41254359Sroberto
413182007Sroberto			printf("  DCF77 monitor %s - Copyright (C) 1993-2005, Frank Kardel\n\n", revision);
41454359Sroberto
41554359Sroberto			clock_time.hour = 0;
41654359Sroberto			clock_time.minute = 0;
41754359Sroberto			clock_time.day = 0;
41854359Sroberto			clock_time.wday = 0;
41954359Sroberto			clock_time.month = 0;
42054359Sroberto			clock_time.year = 0;
42154359Sroberto			clock_time.flags = 0;
42254359Sroberto			buf[60] = '\0';
42354359Sroberto			for ( i = 0; i < 60; i++)
42454359Sroberto			    buf[i] = '.';
42554359Sroberto
42654359Sroberto			gettimeofday(&tlast, 0L);
42754359Sroberto			i = 0;
42854359Sroberto			while (read(fd, &c, 1) == 1)
42954359Sroberto			{
43054359Sroberto				gettimeofday(&t, 0L);
43154359Sroberto				tt = t;
43254359Sroberto				t.tv_sec -= tlast.tv_sec;
43354359Sroberto				t.tv_usec -= tlast.tv_usec;
43454359Sroberto				if (t.tv_usec < 0)
43554359Sroberto				{
43654359Sroberto					t.tv_usec += 1000000;
43754359Sroberto					t.tv_sec  -= 1;
43854359Sroberto				}
43954359Sroberto
44054359Sroberto				if (errs > LINES)
44154359Sroberto				{
44254359Sroberto					printf("  %s", &"PTB private....RADMLSMin....PHour..PMDay..DayMonthYear....P\n"[offset]);
44354359Sroberto					printf("  %s", &"---------------RADMLS1248124P124812P1248121241248112481248P\n"[offset]);
44454359Sroberto					errs = 0;
44554359Sroberto				}
44654359Sroberto
44754359Sroberto				if (t.tv_sec > 1 ||
44854359Sroberto				    (t.tv_sec == 1 &&
44954359Sroberto				     t.tv_usec > 500000))
45054359Sroberto				{
45154359Sroberto					printf("%c %.*s ", pat[i % (sizeof(pat)-1)], 59 - offset, &buf[offset]);
45254359Sroberto
45354359Sroberto					if ((rtc = convert_rawdcf((unsigned char *)buf, i, &clock_time)) != CVT_OK)
45454359Sroberto					{
45554359Sroberto						printf("\n");
45654359Sroberto						clock_time.hour = 0;
45754359Sroberto						clock_time.minute = 0;
45854359Sroberto						clock_time.day = 0;
45954359Sroberto						clock_time.wday = 0;
46054359Sroberto						clock_time.month = 0;
46154359Sroberto						clock_time.year = 0;
46254359Sroberto						clock_time.flags = 0;
46354359Sroberto						errs++;
46454359Sroberto					}
46554359Sroberto
46654359Sroberto					if (((c^0xFF)+1) & (c^0xFF))
46754359Sroberto					    buf[0] = '?';
46854359Sroberto					else
46954359Sroberto					    buf[0] = type(c) ? '#' : '-';
47054359Sroberto
47154359Sroberto					for ( i = 1; i < 60; i++)
47254359Sroberto					    buf[i] = '.';
47354359Sroberto
47454359Sroberto					i = 0;
47554359Sroberto				}
47654359Sroberto				else
47754359Sroberto				{
47854359Sroberto					if (((c^0xFF)+1) & (c^0xFF))
47954359Sroberto					    buf[i] = '?';
48054359Sroberto					else
48154359Sroberto					    buf[i] = type(c) ? '#' : '-';
48254359Sroberto
48354359Sroberto					printf("%c %.*s ", pat[i % (sizeof(pat)-1)], 59 - offset, &buf[offset]);
48454359Sroberto				}
48554359Sroberto
48654359Sroberto				if (rtc == CVT_OK)
48754359Sroberto				{
48854359Sroberto					printf("%s, %2d:%02d:%02d, %d.%02d.%02d, <%s%s%s%s>",
48954359Sroberto					       wday[clock_time.wday],
49054359Sroberto					       (int)clock_time.hour, (int)clock_time.minute, (int)i, (int)clock_time.day, (int)clock_time.month,
49154359Sroberto					       (int)clock_time.year,
49254359Sroberto					       (clock_time.flags & DCFB_ALTERNATE) ? "R" : "_",
49354359Sroberto					       (clock_time.flags & DCFB_ANNOUNCE) ? "A" : "_",
49454359Sroberto					       (clock_time.flags & DCFB_DST) ? "D" : "_",
49554359Sroberto					       (clock_time.flags & DCFB_LEAP) ? "L" : "_"
49654359Sroberto					       );
49754359Sroberto					if (trace && (i == 0))
49854359Sroberto					{
49954359Sroberto						printf("\n");
50054359Sroberto						errs++;
50154359Sroberto					}
50254359Sroberto				}
50354359Sroberto
50454359Sroberto				printf("\r");
50554359Sroberto
50654359Sroberto				if (i < 60)
50754359Sroberto				{
50854359Sroberto					i++;
50954359Sroberto				}
51054359Sroberto
51154359Sroberto				tlast = tt;
51254359Sroberto
51354359Sroberto				fflush(stdout);
51454359Sroberto			}
51554359Sroberto			close(fd);
51654359Sroberto		}
51754359Sroberto	}
51854359Sroberto	return 0;
51954359Sroberto}
520182007Sroberto
521182007Sroberto/*
522182007Sroberto * History:
523182007Sroberto *
524182007Sroberto * testdcf.c,v
525182007Sroberto * Revision 4.10  2005/08/06 14:18:43  kardel
526182007Sroberto * cleanup warnings
527182007Sroberto *
528182007Sroberto * Revision 4.9  2005/08/06 14:14:38  kardel
529182007Sroberto * document revision on startup
530182007Sroberto *
531182007Sroberto * Revision 4.8  2005/08/06 14:10:08  kardel
532182007Sroberto * fix setting of baud rate
533182007Sroberto *
534182007Sroberto * Revision 4.7  2005/04/16 17:32:10  kardel
535182007Sroberto * update copyright
536182007Sroberto *
537182007Sroberto * Revision 4.6  2004/11/14 15:29:42  kardel
538182007Sroberto * support PPSAPI, upgrade Copyright to Berkeley style
539182007Sroberto *
540182007Sroberto */
541