5 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_COMPUTIME)
7 * /src/NTP/ntp-4/libparse/clk_computime.c,v 4.6 1999/11/28 09:13:49 kardel RELEASE_19991128_A
9 * clk_computime.c,v 4.6 1999/11/28 09:13:49 kardel RELEASE_19991128_A
11 * Supports Diem's Computime Radio Clock
13 * Used the Meinberg clock as a template for Diem's Computime Radio Clock
15 * adapted by Alois Camenzind <alois.camenzind@ubs.ch>
17 * Copyright (C) 1992-1998 by Frank Kardel
18 * Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
20 * This program is distributed in the hope that it will be useful, but WITHOUT
21 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 * FITNESS FOR A PARTICULAR PURPOSE.
27 #include "ntp_unixtime.h"
28 #include "ntp_calendar.h"
29 #include "ntp_stdlib.h"
36 #include "sys/parsestreams.h"
37 extern void printf P((const char *, ...));
41 * The Computime receiver sends a datagram in the following format every minute
43 * Timestamp T:YY:MM:MD:WD:HH:MM:SSCRLF
44 * Pos 0123456789012345678901 2 3
45 * 0000000000111111111122 2 2
46 * Parse T: : : : : : : rn
48 * T Startcharacter "T" specifies start of the timestamp
49 * YY Year MM Month 1-12
60 static struct format computime_fmt =
63 {8, 2}, {5, 2}, {2, 2}, /* day, month, year */
64 {14, 2}, {17, 2}, {20, 2}, /* hour, minute, second */
65 {11, 2}, /* dayofweek, */
67 (const unsigned char *)"T: : : : : : : \r\n",
71 static u_long cvt_computime P((unsigned char *, int, struct format *, clocktime_t *, void *));
72 static unsigned long inp_computime P((parse_t *, unsigned int, timestamp_t *));
74 clockformat_t clock_computime =
76 inp_computime, /* Computime input handling */
77 cvt_computime, /* Computime conversion */
78 0, /* no PPS monitoring */
79 (void *)&computime_fmt, /* conversion configuration */
80 "Diem's Computime Radio Clock", /* Computime Radio Clock */
81 24, /* string buffer */
82 0 /* no private data (complete pakets) */
88 * convert simple type format
92 unsigned char *buffer,
94 struct format *format,
95 clocktime_t *clock_time,
100 if (!Strok(buffer, format->fixed_string)) {
103 if (Stoi(&buffer[format->field_offsets[O_DAY].offset], &clock_time->day,
104 format->field_offsets[O_DAY].length) ||
105 Stoi(&buffer[format->field_offsets[O_MONTH].offset], &clock_time->month,
106 format->field_offsets[O_MONTH].length) ||
107 Stoi(&buffer[format->field_offsets[O_YEAR].offset], &clock_time->year,
108 format->field_offsets[O_YEAR].length) ||
109 Stoi(&buffer[format->field_offsets[O_HOUR].offset], &clock_time->hour,
110 format->field_offsets[O_HOUR].length) ||
111 Stoi(&buffer[format->field_offsets[O_MIN].offset], &clock_time->minute,
112 format->field_offsets[O_MIN].length) ||
113 Stoi(&buffer[format->field_offsets[O_SEC].offset], &clock_time->second,
114 format->field_offsets[O_SEC].length)) {
115 return CVT_FAIL | CVT_BADFMT;
118 clock_time->flags = 0;
119 clock_time->utcoffset = 0; /* We have UTC time */
129 * grep data from input stream
140 parseprintf(DD_PARSE, ("inp_computime(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
145 parseprintf(DD_PARSE, ("inp_computime: START seen\n"));
147 parseio->parse_index = 1;
148 parseio->parse_data[0] = ch;
149 parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
150 return PARSE_INP_SKIP;
153 parseprintf(DD_PARSE, ("inp_computime: END seen\n"));
154 if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
155 return parse_end(parseio);
160 return parse_addchar(parseio, ch);
164 #else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_COMPUTIME) */
165 int clk_computime_bs;
166 #endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_COMPUTIME) */
170 * Revision 4.6 1999/11/28 09:13:49 kardel
173 * Revision 4.5 1998/06/14 21:09:34 kardel
176 * Revision 4.4 1998/06/13 12:00:38 kardel
177 * fix SYSV clock name clash
179 * Revision 4.3 1998/06/12 15:22:26 kardel
182 * Revision 4.2 1998/06/12 09:13:24 kardel
183 * conditional compile macros fixed
186 * Revision 4.1 1998/05/24 09:39:51 kardel
187 * implementation of the new IO handling model
189 * Revision 4.0 1998/04/10 19:45:27 kardel
190 * Start 4.0 release version numbering
192 * from V3 1.8 log info deleted 1998/04/11 kardel