find year, month, day, hour, minute, second, status (synchronised or not), possibly time zone information (you need to give the offset to UTC) You will have to convert the data from a string into a struct clocktime:
struct clocktime /* clock time broken up from time code */
{
long day;
long month;
long year;
long hour;
long minute;
long second;
long usecond;
long utcoffset; /* in seconds */
time_t utcoffset; /* true utc time instead of date/time */
long flags; /* current clock status */
};
Conversion is usually simple and straight forward. For the flags following values can be OR'ed together:
PARSEB_ANNOUNCE switch time zone warning (informational only)
PARSEB_POWERUP no synchronisation - clock confused (must set then)
PARSEB_NOSYNC timecode currently not confirmed (must set then)
usually on reception error when there is still a
chance the the generated time is still ok.
PARSEB_DST DST in effect (informational only)
PARSEB_UTC timecode contains UTC time (informational only)
PARSEB_LEAPADD LEAP addition warning (prior to leap happening - must set when imminent)
also used for time code that do not encode the
direction (as this is currently the default).
PARSEB_LEAPDEL LEAP deletion warning (prior to leap happening - must set when imminent)
PARSEB_ALTERNATE backup transmitter (informational only)
PARSEB_POSITION geographic position available (informational only)
PARSEB_LEAPSECOND actual leap second (this time code is the leap
second - informational only)
These are feature flags denoting items that are supported by the clock:
PARSEB_S_LEAP supports LEAP - might set PARSEB_LEAP
PARSEB_S_ANTENNA supports ANTENNA - might set PARSEB_ALTERNATE
PARSEB_S_PPS supports PPS time stamping
PARSEB_S_POSITION supports position information (GPS)
If the utctime field is non zero this value will be take as time code value. This allows for conversion routines that already have the utc time value. The utctime field gives the seconds since Jan 1st 1970, 0:00:00. The useconds field gives the respective usec value. The fields for date and time (down to second resolution) will be ignored.
Conversion is done in the cvt_* routine in parse/clk_*.c files. look in them for examples. The basic structure is:
struct clockformat <yourclock>_format = {
lots of fields for you to fill out (see below)
};
static cvt_<yourclock>()
...
{
if (<I do not recognize my time code>) {
return CVT_NONE;
} else {
if (<conversion into clockformat is ok>) {
<set all necessary flags>;
return CVT_OK;
} else {
return CVT_FAIL|CVT_BADFMT;
}
}
The struct clockformat is the interface to the rest of the parse driver - it holds all information necessary for finding the clock message and doing the appropriate time stamping.
struct clockformat
{
u_long (*input)();
/* input routine - your routine - cvt_<yourclock> */
u_long (*convert)();
/* conversion routine - your routine - cvt_<yourclock> */
/* routine for handling RS232 sync events (time stamps) - usually sync_simple */
u_long (*syncpps)();
/* PPS input routine - usually pps_one */
void *data;
/* local parameters - any parameters/data/configuration info your conversion
routine might need */
char *name;
/* clock format name - Name of the time code */
unsigned short length;
/* maximum length of data packet for your clock format */
u_long flags;
/* information for the parser what to look for */
};
The above should have given you some hints on how to build a clk_*.c file with the time code conversion. See the examples and pick a clock closest to yours and tweak the code to match your clock.
In order to make your clk_*.c file usable a reference to the clockformat structure must be put into parse_conf.c.