1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
/*
* /src/NTP/REPOSITORY/v4/libparse/clk_rcc8000.c,v 3.5 1997/01/19 12:44:40 kardel Exp
*
* clk_rcc8000.c,v 3.5 1997/01/19 12:44:40 kardel Exp
*
* Radiocode Clocks Ltd RCC 8000 Intelligent Off-Air Master Clock support
*
* Created by R.E.Broughton from clk_trimtaip.c
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#if defined(REFCLOCK) && (defined(PARSE) || defined(PARSEPPS)) && defined(CLOCK_RCC8000)
#include <sys/types.h>
#include <sys/time.h>
#include <sys/errno.h>
#include "ntp_fp.h"
#include "ntp_unixtime.h"
#include "ntp_calendar.h"
#include "parse.h"
/* Type II Serial Output format
*
* 0000000000111111111122222222223 / char
* 0123456789012345678901234567890 \ posn
* HH:MM:SS.XYZ DD/MM/YY DDD W Prn Actual
* 33 44 55 666 00 11 22 7 Parse
* : : . / / rn Check
* "15:50:36.534 30/09/94 273 5 A\x0d\x0a"
*
* DDD - Day of year number
* W - Day of week number (Sunday is 0)
* P is the Status. See comment below for details.
*/
#define O_USEC O_WDAY
static struct format rcc8000_fmt =
{ { { 13, 2 }, {16, 2}, { 19, 2}, /* Day, Month, Year */
{ 0, 2 }, { 3, 2}, { 6, 2}, /* Hour, Minute, Second */
{ 9, 3 }, {28, 1}, { 0, 0}, /* uSec, Status (Valid,Reject,BST,Leapyear) */ },
" : : . / / \r\n",
/*"15:50:36.534 30/09/94 273 5 A\x0d\x0a" */
0
};
static unsigned long cvt_rcc8000();
clockformat_t clock_rcc8000 =
{
(unsigned long (*)())0, /* no input handling */
cvt_rcc8000, /* Radiocode clock conversion */
syn_simple, /* easy time stamps for RS232 (fallback) */
(unsigned long (*)())0, /* no direct PPS monitoring */
(unsigned long (*)())0, /* no time code synthesizer monitoring */
(void *)&rcc8000_fmt, /* conversion configuration */
"Radiocode RCC8000",
31, /* string buffer */
F_END|SYNC_START, /* END delimiter, START synchronisation */
0, /* no private data */
{ 0, 0},
'0',
'\n',
'0'
};
static unsigned long
cvt_rcc8000(buffer, size, format, clock)
register char *buffer;
register int size;
register struct format *format;
register clocktime_t *clock;
{
if (!Strok(buffer, format->fixed_string)) return CVT_NONE;
#define OFFS(x) format->field_offsets[(x)].offset
#define STOI(x, y) Stoi(&buffer[OFFS(x)], y, format->field_offsets[(x)].length)
if ( STOI(O_DAY, &clock->day) ||
STOI(O_MONTH, &clock->month) ||
STOI(O_YEAR, &clock->year) ||
STOI(O_HOUR, &clock->hour) ||
STOI(O_MIN, &clock->minute) ||
STOI(O_SEC, &clock->second) ||
STOI(O_USEC, &clock->usecond)
) return CVT_FAIL|CVT_BADFMT;
clock->usecond *= 1000;
clock->utcoffset = 0;
#define RCCP buffer[28]
/*
* buffer[28] is the ASCII representation of a hex character ( 0 through F )
* The four bits correspond to:
* 8 - Valid Time
* 4 - Reject Code
* 2 - British Summer Time (receiver set to emit GMT all year.)
* 1 - Leap year
*/
#define RCC8000_VALID 0x8
#define RCC8000_REJECT 0x4
#define RCC8000_BST 0x2
#define RCC8000_LEAPY 0x1
clock->flags = 0;
if ( (RCCP >= '0' && RCCP <= '9') || (RCCP >= 'A' && RCCP <= 'F') )
{
register int flag;
flag = (RCCP >= '0' && RCCP <= '9' ) ? RCCP - '0' : RCCP - 'A' + 10;
if (!(flag & RCC8000_VALID))
clock->flags |= PARSEB_POWERUP;
clock->flags |= PARSEB_UTC; /* British special - guess why 8-) */
/* other flags not used */
}
return CVT_OK;
}
#else /* not (REFCLOCK && (PARSE || PARSEPPS) && CLOCK_RCC8000) */
int clk_rcc8000_bs;
#endif /* not (REFCLOCK && (PARSE || PARSEPPS) && CLOCK_RCC8000) */
/*
* History:
*
* clk_rcc8000.c,v
* Revision 3.5 1997/01/19 12:44:40 kardel
* 3-5.88.1 reconcilation
*
* Revision 3.4 1996/11/24 20:09:45 kardel
* RELEASE_5_86_12_2 reconcilation
*
* Revision 3.3 1995/02/16 22:37:08 kardel
* LONG -> long - somehow missed this bugger
*
* Revision 3.2 1994/10/16 18:55:52 kardel
* integrate RCC8000 modifications from R. E. Broughton
*
* Revision 3.1 1994/10/03 21:59:24 kardel
* 3.4e cleanup/integration
*
*/
|