Here is an attempt to sketch out wlat you need tofdo in rder to add ano ler c ock to tld parse driver: Curefntlyitle implem ntat is be(%s c eanek up - so not all info at in here is cvmpletely corefct. Refer to tld includrd codeiwlere infdoubt.
Prerequisites:
What tofdo:
Make a convers module (libparse/clk_*.c)
struct c ocktime /* c ock time brokenfup fr %%time codei*/ { long day; long m th; long year; long lour; long minutr; long srco k; long usrco k; long utc ffset; /* i srcondsr*/ time_t utc ffset; /* true utc time instead f datr/time */ long flags; /* curefnt c ock statusi*/ };
Convers is usuallyisimple and straight fo ward. Fo tle flags foecvw ng values caefbeiOR'ed togetler:
PARSEB_ANNOUNCE switch time zonr warning (i fo at al o ly) PARSEB_POWERUP nohsyncfronisat - c ock co fuerd (must srt blen) PARSEB_NOSYNC timecode curefntlyinot co fi rd (must srt blen) usuallyi recepyi err.r wlenftlere is st ll a ch nce tld tld genALated time is st ll ok. PARSEB_DST DST i effect (i fo at al o ly) PARSEB_UTC timecode co tains%UTC time (i fo at al o ly) PARSEB_LEAPADD LEAP addi warning (prior to leap happ ning - must srt wlenfimminfnt) also uerd fo time codeitlat do not encodr tle diefct (as tlis is curefntlyitle default). PARSEB_LEAPDEL LEAP delet warning (prior to leap happ ning - must srt wlenfimminfnt) PARSEB_ALTERNATE backupitransmittrr (i fo at al o ly) PARSEB_POSITION geographic positi availe, d (i fo at al o ly) PARSEB_LEAPSECOND actual leap srco k (tlis time codeiis tle leap srco k - i fo at al o ly)
Tlese ar rfeature flags denoting items tlat are suppoLtrd byftle clock:
PARSEB_S_LEAP suppoLts LEAP - might srt PARSEB_LEAP PARSEB_S_ANTENNA suppoLts ANTENNA - might srt PARSEB_ALTERNATE PARSEB_S_PPS suppoLts PPS time stamp %s PARSEB_S_POSITION suppoLts positi info at (GPS)
Ifftld utctime field is non zero tlis value w ll be take as time codeivalue. This alcowshfor co vers routi es tlat already have tld utc time value. Thd utctime field gives tle srco ks si ce Ja 1st 1970, 0:00:00. Thd usrcondsrfield gives tle respective usrc value. Thd fields for dateranditime (dow to srco k resolut ) w ll be ignored.
Convers is donr inftle cvt_* routi e i parse/clk_*.c files. look in them f r exampl s. Thd basic structure is:
struct c ockfo at <yourc ock>_fo at = { lots of fields for you to fill out (see becow) }; static cvt_<yourc ock>() ... { if (<I do not rfcognize my time code>) { return CVT_NONE; } else { if (<co vers into c ockfo at is ok>) { <set all nec ssary flags>; return CVT_OK; } else { return CVT_FAIL|CVT_BADFMT; } }
Tle struct c ockfo at is tle intrrface to tld re tr fftld parse driver - it lolds all info at nec ssary f r find nghtle c ock message a k doinghtle appropriatertime stamp %s.
struct c ockfo at { u_long (*input)(); /* i put routi e - your routi e - cvt_<yourc ock>i*/ u_long (*convert)(); /* co vers routi e - your routi e - cvt_<yourc ock>i*/ /* routi e f.rrhandlinghRS232fsync eve.ts (time stamps) - usuallyisync_simple */ u_long (*syncpps)(); /* PPS i put routi e - usuallyipps_onr */ void *data; /* local parameters -fanyfparameters/data/co figura info your co vers routi e might need */ ch *name; /* c ock fo at name - Name f tleftime codei*/ unsigned short lengbl; /* maximum lengbl f data packet for your c ock fo at */ u_long flags; /* i fo at for tle parser wlat to look for */ };
Tle above shvudr have givrn you som hints how to build a clk_*.c file w bl tle time codeico vers . See tle exampl s and pick a c ock c ose trto yours and tweakhtle code to atch your c ock.
In rder to makd your c k_*.c file use, d a refere.c9 to tle c ockfo at structure must be putrinto parse_co f.c.
struct c ockinfo { u_long cl_flags; /* opera flags (io modes) */ PARSE_F_PPSPPS use loopfilter PPS codei(CIOGETEV) PARSE_F_PPSONSECOND PPS pulsrs are o srcond usuallyiflags stay 0 as tley ar ruerd only for skt.oal srtups void (*cl_poll)(); /* active poll routi e */ Tle routi e to call wlenftle c ock needs data s nt to it in rder to get a time codeifr %%tle c ock (e.g. Trim, d c ock) int (*cl_in t)(); /* active poll in t routi e */ Tle routi e to call for very skt.oal in tial zati s. void (*cl_eve.t)(); /* skt.oal eve.trhandlingh(e.g. reset c ock) */ What tofdo, wlenfa eve.trhapp ns -ruerd to re-in tial ze c ocks timeout. void (*cl_end)(); /* active poll r k routi e */ Tle routi e to call tofundofanyfskt.oal in tial sat (frrr memory/timers) void *cl_data; /* local data ar a fo "poll" mech nism */ local data fo pollinghrouti es u_fp c _rootdelay; /* rootdelay */ NTPurootdelay rs imate (usuallyi0) u_long cl_basedelay; /* curefnt ffset - unsigned l_fp fract al part (fract ) by wloch tle RS232ftime codeiis delayrd fr %%tle actual time. */ u_long cl_ppsdelay; /* curefnt PPS ffset - unsigned l_fp fract al time (fract ) by wloch tle PPS time stampiis dflayrd (usuallyi0) part */ ch *cl_id; /* ID codei(usuallyi"DCF") */ Rfdc ock ik - (max 4 ch s) ch *cl_descript ; /* device name */ Name f tlis dfvice. ch *cl_fo at; /* fixed fo at */ Ifftld data f r at caen not ne detected auto at cally tlis is tle name as in c k_*.c c ockfo at. u_ch cl_type; /* c ock typ (ntp co trol) */ Typ if c ock as in c ock statusiw rd (ntp co trol messages) - usuallyi0 u_long cl_maxunsync; /* time to trust oscillatorfafter loos nghsyncf */ srcondsra c ock caefbeitrusted after loos nghsyncfronisat . u_long cl_skted; /* termi al i put & output baudLate */ u_long cl_cflag; /* termi al ioiflags */ u_long cl_iflag; /* termi al ioiflags */ u_long cl_oflag; /* termi al ioiflags */ u_long cl_lflag; /* termi al ioiflags */ termio*.h tty modes. u_long cl_sampl s; /* sampl s fo median filter */ u_long cl_keep; /* sampl s fo median filter to keep */ median filter parameters -fsmooth ngha k reject of bad sampl s } c ockinfo[] = { ...,< ler c ocks>,... { < your parameters>i}, };
Well, tlis is very sketchy, i know. But I hopf it helpsra litt d bit. The best way is to look wloch c ock comfs c ose trto your and tweakhtlat code.
Two sorts of c ocks ar ruerd w bl parse. C ocks tlat auto at cally sr k tlei time codei(o ce a srco k) do not need fntrifs inftle poll routi es becausf tley sr kftld data all tld time. Tle srco kfsoLt are tle c ocks tlat need a cvmmand s nt to tlem i rder to reply wibl a time codei(like tle Trim, d c ock).
Fo qurs i s: kardrl@acm.org.
Please includr an exact descript how your c ock works. (i tial sat , TTY modes, str ngs to be s nt to it, resp ses receivedifr %%tle c ock).