2 * /src/NTP/ntp-4/libparse/clk_dcf7000.c,v 4.6 1999/11/28 09:13:49 kardel RELEASE_19991128_A
4 * clk_dcf7000.c,v 4.6 1999/11/28 09:13:49 kardel RELEASE_19991128_A
8 * Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998 by Frank Kardel
9 * Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_DCF7000)
24 #include "ntp_unixtime.h"
25 #include "ntp_calendar.h"
30 #include "ntp_stdlib.h"
33 #include "sys/parsestreams.h"
34 extern void printf P((const char *, ...));
37 static struct format dcf7000_fmt =
40 { 6, 2}, { 3, 2}, { 0, 2},
41 { 12, 2}, { 15, 2}, { 18, 2},
44 (const unsigned char *)" - - - - - - - \r",
47 static u_long cvt_dcf7000 P((unsigned char *, int, struct format *, clocktime_t *, void *));
48 static unsigned long inp_dcf7000 P((parse_t *, unsigned int, timestamp_t *));
50 clockformat_t clock_dcf7000 =
52 inp_dcf7000, /* DCF7000 input handling */
53 cvt_dcf7000, /* ELV DCF77 conversion */
54 0, /* no direct PPS monitoring */
55 (void *)&dcf7000_fmt, /* conversion configuration */
56 "ELV DCF7000", /* ELV clock */
57 24, /* string buffer */
58 0 /* no private data (complete pakets) */
64 * convert dcf7000 type format
68 unsigned char *buffer,
70 struct format *format,
71 clocktime_t *clock_time,
75 if (!Strok(buffer, format->fixed_string))
81 if (Stoi(&buffer[format->field_offsets[O_DAY].offset], &clock_time->day,
82 format->field_offsets[O_DAY].length) ||
83 Stoi(&buffer[format->field_offsets[O_MONTH].offset], &clock_time->month,
84 format->field_offsets[O_MONTH].length) ||
85 Stoi(&buffer[format->field_offsets[O_YEAR].offset], &clock_time->year,
86 format->field_offsets[O_YEAR].length) ||
87 Stoi(&buffer[format->field_offsets[O_HOUR].offset], &clock_time->hour,
88 format->field_offsets[O_HOUR].length) ||
89 Stoi(&buffer[format->field_offsets[O_MIN].offset], &clock_time->minute,
90 format->field_offsets[O_MIN].length) ||
91 Stoi(&buffer[format->field_offsets[O_SEC].offset], &clock_time->second,
92 format->field_offsets[O_SEC].length))
94 return CVT_FAIL|CVT_BADFMT;
98 unsigned char *f = &buffer[format->field_offsets[O_FLAGS].offset];
101 clock_time->flags = 0;
102 clock_time->usecond = 0;
104 if (Stoi(f, &flags, format->field_offsets[O_FLAGS].length))
106 return CVT_FAIL|CVT_BADFMT;
111 clock_time->utcoffset = -2*60*60;
113 clock_time->utcoffset = -1*60*60;
116 clock_time->flags |= PARSEB_ANNOUNCE;
119 clock_time->flags |= PARSEB_NOSYNC;
129 * grep data from input stream
140 parseprintf(DD_PARSE, ("inp_dcf7000(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
145 parseprintf(DD_PARSE, ("inp_dcf7000: EOL seen\n"));
146 parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
147 if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
148 return parse_end(parseio);
153 return parse_addchar(parseio, ch);
157 #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_DCF7000) */
159 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_DCF7000) */
165 * Revision 4.6 1999/11/28 09:13:49 kardel
168 * Revision 4.5 1998/06/14 21:09:34 kardel
171 * Revision 4.4 1998/06/13 12:01:59 kardel
172 * fix SYSV clock name clash
174 * Revision 4.3 1998/06/12 15:22:27 kardel
177 * Revision 4.2 1998/06/12 09:13:24 kardel
178 * conditional compile macros fixed
181 * Revision 4.1 1998/05/24 09:39:51 kardel
182 * implementation of the new IO handling model
184 * Revision 4.0 1998/04/10 19:45:28 kardel
185 * Start 4.0 release version numbering
187 * from V3 3.18 log info deleted 1998/04/11 kardel