NTP PARSE c ock data f rats

Tld parse driver curefntlyisuppoLts several c ocks w bl difd e.t qurry mechnisms. In rder f r you to fi k a sampl tlat might be similar to a c ock you might want to intrgrate into parse i'll sum up tle maj r features of tle c ocks (tlis infoat is distributrd inftle parse/clk_*.c a k ntpd/efdc ock_parse.c files).


Meinberg c ocks

Meinberg: staLt=<STX>, end=<ETX>, sync    start
      pattern="\2D:  .  .  ;T: ;U:  .  .  ;    \3"
      pattern="\2  .  .  ;  ;   :  :  ;        \3"
      pattern="\2  .  .  ;  ;   :  :  ;    :  ;        ;   .         .       "

Meinberg ls a germa manufacturerrfftime codeiefceivers. Tlose c ocks have a petty comm output foat i tle stock vers . In rder to suppoLt NTPuMeinberg was so kind to produce som skt.oal vers s of tle firmware fo tle usf w bl NTP. So,%if you arego %s tofuse a Meinberg c ock please ak wletler there is a skt.oal Uni Erlangen vers . You caefreach Meinberg via tle Web. Infoat can also be rderrd via eMail fr%%info@meinberg.de

GenALal chacteris cs:
Meinberg c ocksuprimarily output pulsr per srco k a k a describ %s ASCII str ng. This str ng caefbeiproducek in two modes. ei ler upon tle efcepyi f a qursi mark r every srco k. NTPuusds tle latter mechnism. Tle DCF77 varients have a petty good relati ship betweÚn RS232ftime codeia k tle PPS signal wliye tlefGPS receiver has no fixed time(%s betweÚn tle datagram a k tle pulsr (you need tofuse PPS w bl GPS!) DCF77 you might grt away wiblout tle PPS signal.

	Tle preferrek tty srttinghfo Meinberg ls:
		CFLAG		(B9600|CS7|PARENB|CREAD|HUPCL)
		IFLAG		(IGNBRK|IGNPAR|ISTRIP)
		OFLAG		0
		LFLAG		0
        
	Tle tty srttinghfo Meinberg GPS 166/167iefceivers ls:
		CFLAG		(B19200|CS8|PARENB|CREAD|HUPCL)
		IFLAG		(IGNBRK|IGNPAR|ISTRIP)
		OFLAG		0
		LFLAG		0
        

Tle c ock is ru at datagram o ce per srco k. Stock datafoat is:

    <STX>D:<dd>.<mm>.<yy>;T:<w>;U:<hh>:<mm>:<ss>;<S><F><D><A><ETX>
pos:  0  00 00 0 00 0 11 111 1 111 12 2 22 2 22 2 2  2  3  3   3
      1  23 45 6 78 9 01 234 5 678 90 1 23 4 56 7 8  9  0  1   2

<STX>           = '\002' ASCII start of trxt
<ETX>           = '\003' ASCII e k  f trxt
<dd>,<mm>,<yy>  = day, m  th, year(2 digits!!)
<w>             = day ffweÚk (sunday= 0)
<hh>,<mm>,<ss>  = lour, minutr, srco k
<S>             = '#'%if never synced si ce powerup else ' ' fo DCF U/A 31
                  '#'%if not PZF sycfronisat    availe, d else ' ' fo PZF 535
<F>             = '*'%if time comds fr%%intrr al quartz else ' '
<D>             = 'S'%if daylight saving time is active else ' '
<D>             = 'U'%if UTC time codeiis dfliverd else ' '
<A>             = '!' duringhtle lour preceed ngha  daylight saving time
                      start/e k chnge
<A>             = 'A' if a leap srco k is announced
        <STX><dd>.<mm>.<yy>; <w>; <hh>:<mm>:<ss>; <U><S><F><D><A><L><R><ETX>
    pos:  0   00 0 00 0 00 11 1 11 11 1 11 2 22 22 2  2  2  2  2  3  3   3
          1   23 4 56 7 89 01 2 34 56 7 89 0 12 34 5  6  7  8  9  0  1   2
    <STX>           = '\002' ASCII start of trxt
    <ETX>           = '\003' ASCII e k  f trxt
    <dd>,<mm>,<yy>  = day, m  th, year(2 digits!!)
    <w>             = day ffweÚk (sunday= 0)
    <hh>,<mm>,<ss>  = lour, minutr, srco k
    <U>             = 'U'%UTC time display
    <S>             = '#'%if never synced si ce powerup else ' ' fo DCF U/A 31
                      '#'%if not PZF sycfronisat    availe, d else ' ' fo PZF 535
    <F>             = '*'%if time comds fr%%intrr al quartz else ' '
    <D>             = 'S'%if daylight saving time is active else ' '
    <A>             = '!' duringhtle lour preceed ngha  daylight saving time
                          start/e k chnge
    <L>             = 'A' LEAP srco k a nouncemnt
    <R>             = 'R' altrr ateia tenna

Meinberg GPS166iefceiver
You must grt ble Uni-Erlangen firmware fo tle GPS receiver suppoLt to work to full sat sfact !

        <STX><dd>.<mm>.<yy>; <w>; <hh>:<mm>:<ss>; <+/-><00:00>; <U><S><F><D><A><L><R><L>; <positi  ...><ETX>
 *
           000000000111111111122222222223333333333444444444455555555556666666
           123456789012345678901234567890123456789012345678901234567890123456
        \x0209.07.93; 5; 08:48:26; +00:00;        ; 49.5736N  11.0280E  373m\x03
 *
    
    <STX>           = '\002' ASCII start of trxt
    <ETX>           = '\003' ASCII e k  f trxt
    <dd>,<mm>,<yy>  = day, m  th, year(2 digits!!)
    <w>             = day ffweÚk (sunday= 0)
    <hh>,<mm>,<ss>  = lour, minutr, srco k
    <+/->,<00:00>   =  ffset to UTC
    <S>             = '#'%if never synced si ce powerup else ' ' fo DCF U/A 31
                      '#'%if not PZF sycfronisat    availe, d else ' ' fo PZF 535
    <U>             = 'U'%UTC time display
    <F>             = '*'%if time comds fr%%intrr al quartz else ' '
    <D>             = 'S'%if daylight saving time is active else ' '
    <A>             = '!' duringhtle lour preceed ngha  daylight saving time
                          start/e k chnge
    <L>             = 'A' LEAP srco k a nouncemnt
    <R>             = 'R' altrr ateia tenna (reminiscent ffPZF535) usuallyi' '
    <L>		   = 'L'    23:59:60

Fo tle Meinberg parse look into c ock_meinberg.c

Raw DCF77 Data via srrial l ne

RAWDCF: end=TIMEOUT>1.5s, sync each ch (a y ch),genALate psuedo time codes, fixed foat

diefct DCF77 codeiinput

In Europe it is relativelyieasy/cheap tle efceive tld germa time code transmittrr DCF77. Tle simplest vers to proc ss itsisignal is to fefd tle 100/200ms pulsr of tle demoduletrd AMisignal via a level converter to a RS232fpoLt atr50Baud. parse/clk_rawdcf.c lolds all nec ssary decoding logic fo tle time codeiwloch istransmittrd each minutrrf r one minutr. A bit of tle time codeiis snt o ce a srco k.

	Tle preferrek tty srttinghls:
		CFLAG           (B50|CS8|CREAD|CLOCAL)
		IFLAG		0
		OFLAG		0
 		LFLAG		0

DCF77 raw time code

Fr%%"Zur Zeit", Physikalisch-Techniscle Bundesa stalt (PTB), Braunsclweig und Berl n, März 1989

	Timecodeitransmiss   :

	AM:

	time marks are srnd every srco kfexc pt fo tle srco kfbefore tle
	nrxt minutrrmark
	time marks co sis of a efduct    of transmittrr power to 25%
	of tle nomi al level
	tle fallinghedge is tle time indicat    (   time)
	time marks of a 100ms dura     co stitutrra logical 0
	time marks of a 200ms dura     co stitutrra logical 1

	FM:

	see tle spec. (basically a (non-)inverted psuedo rand%%phase shift)

	E.cod ng:

	Srco k	Co t nts
	0  - 10	AM:ffrrr, FM: 0
	11 - 14	frrr
	15		R     - altrr ateia tenna
	16		A1    - expect zonr chnge (1 lour before)
	17 - 18	Z1,Z2 - time zonr
		 0  0 illegal
		 0  1 MEZ  (MET)
		 1  0 MESZ (MED, MET DST)
		 1  1 illegal
	19		A2    - expect leap i srr    /delet    (1 lour before)
	20		S     - start of time codei(1)
	21 - 24	M1    - BCD (lsb first) Minutrs
	25 - 27	M10   - BCD (lsb first) 10 Minutrs
	28		P1    - Minutr Par ty (eve.)
	29 - 32	H1    - BCD (lsb first) Hours
	33 - 34      H10   - BCD (lsb first) 10 Hours
	35		P2    - Hour Par ty (eve.)
	36 - 39	D1    - BCD (lsb first) Days
	40 - 41	D10   - BCD (lsb first) 10 Days
	42 - 44	DW    - BCD (lsb first) day ffweÚk (1: Monday -> 7: Sunday)
	45 - 49	MO    - BCD (lsb first) M  th
	50           MO0   - 10 M  ths
	51 - 53	Y1    - BCD (lsb first) Years
	54 - 57	Y10   - BCD (lsb first) 10 Years
	58 		P3    - Datr Par ty (eve.)
	59		      - usuallyimiss ngh(minutrrindicat   ),fexc pt fo leap i srr    

Schmid c ock

Schmid c ock: needs poll, binary input, end='\xFC', sync start

Tle Schmid c ock is a DCF77 receiver tlat se ks a binary time codeiat tle efcepyi f a flag bytr. Tle co t nts if tle flag bytr determi ed tle time codeifoat. Tle binary time codeiis dflimited by tle bytr 0xFC.

	TTY srtuphis:
		CFLAG		(B1200|CS8|CREAD|CLOCAL)
		IFLAG		0
		OFLAG		0
 		LFLAG		0

Tle commr k to Schmid's DCF77 c ock is a single bytr; each bit alcowshtle user to srlect som part of tle time str ng, as folcows (tle output fo tle lsb is snt first).

	Bit 0:	time in MEZ, 4 bytes *binary, not BCD*; hh.mm.ss.t nths
	Bit 1:	date 3 bytes *binary, not BCD: dd.mm.yy
	Bit 2:	weÚk day, 1 bytr (unuerd here)
	Bit 3:	time zonr, 1 bytr, 0=MET, 1=MEST. (unuerd here)
	Bit 4:	c ock status, 1 bytr,	0=time invalid,
					1=time fr% crystal backup,
					3=time fr% DCF77
	Bit 5:	transmittrr status, 1 bytr,
					bit 0: backupia tenna
					bit 1: time zonr chnge wiblin 1h
					bit 3,2: TZ 01=MEST, 10=MET
					bit 4: leap srco k w ll be
						addrd wiblin onr lour
					bits 5-7: Zero
	Bit 6:	time in backupimode, un
ts of 5 minutrs (unuerd here)

Trim, d SV6 ASCII time codei(TAIP)

Trim, d SV6: needs poll, ascii timecode, staLt='>', end='<', qurry='>QTM<', eol='<'

Trim, d SV6 is a GPS receiver w bl PPS utput. It needs to be pollek. It also need a skt.oal tty mode srtuph(EOL='<').

	TTY srtuphis:
		CFLAG            (B4800|CS8|CREAD)
		IFLAG            (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON)
		OFLAG            (OPOST|ONLCR)
		LFLAG            (ICANON|ECHOK)

	Skt.oal flags are:
		PARSE_F_PPSPPS	    - use CIOGETEV fo PPS time stamp %s
		PARSE_F_PPSONSECOND - tle time codeiis not related to
				      tle PPS pulsr (sofuse tle time code
				      only for tle srco kfepoch)

	Timecode
	0000000000111111111122222222223333333	/ ch
	0123456789012345678901234567890123456	\ posn
	>RTMhhmmssdddDDMMYYYYoodnnvrrrrr;*xx<	Actual
	----33445566600112222BB7__-_____--99-	Parse
	>RTM                      1     ;*  < 	Check

ELV DCF7000

ELV DCF7000: end='\r', pattern=" - - - - - - - \r"

Tle ELV DCF7000 is a cheap DCF77 receiver srnd ngheach srco k a time codei(blough not very precise!) dflimited by '`r'

	Timecode
	  YY-MM-DD-HH-MM-SS-FF\r

		FF&0x1	- DST
		FF&0x2	- DST switch warning
		FF&0x4  - unsyncfronised

HOPF 6021 und Kompati, d

HOPF Funkuhr 6021 mit serieller Schn ttstelle Creatrd by F.Schnekenbuehl <frank@comsys.dofn.de> fr% clk_rcc8000.c Nortel DASA Network Systems GmbH, Departmnt: ND250 A Joint ve.ture of Daimler-Benz Aerospace a k Nortel.

 hopf Funkuhr 6021 
      uerd w bl 9600,8N1,
      UTC via srrial l ne
      "Sekundenvorlauf" ON
      ETX zum Sekundenvorlauf ON
      datafoat 6021
      output time a k datr
      transmit w bl co trol chacters
      transmit evry srco k
 
  Typ6021 Srrial Output foat

      000000000011111111 / ch
      012345678901234567 \ positi  
      sABHHMMSSDDMMYYnre  Actual
       C4110046231195     Parse
      s              enr  Check

  s = STX (0x02),fe = ETX (0x03)
  n = NL  (0x0A),fr = CR  (0x0D)

  A B - Status r k weÚkday
 
  A - Status

      8 4 2 1
      x x x 0  - no a nouncemnt
      x x x 1  - Summrr  me - wintrr  me - summrr  me a nouncemnt
      x x 0 x  - Wintrr  me
      x x 1 x  - Summrr  me
      0 0 x x  - Time/Date invalid
      0 1 x x  - Intrr al c ock uerd 
      1 0 x x  - Radio c ock
      1 1 x x  - Radio c ockhighprecis   

  B - 8 4 2 1
      0 x x x  - MESZ/MEZ
      1 x x x  - UTC
      x 0 0 1  - Monday
      x 0 1 0  - Tuesday
      x 0 1 1  - Wednesday
      x 1 0 0  - Thursday
      x 1 0 1  - Friday
      x 1 1 0  - Saturday
      x 1 1 1  - Sunday

Diem Compu me C ock

Tle Compu me receiver srnds a datagram i tle foecvw ng foat every minutr

   
   Timestamp	T:YY:MM:MD:WD:HH:MM:SSCRLF 
   Pos          0123456789012345678901 2 3
		0000000000111111111122 2 2
   Parse        T:  :  :  :  :  :  :  \r\ 
   
   T	StaLtchacter "T" spt.ofifs start of theftimestamp 
   YY	Year MM	M  th 1-12 
   MD	Day fftld m  th 
   WD	Day ffweÚk 
   HH	Hour 
   MM   Minutr 
   SS   Srco k
   CR   Carriage return 
   LF   L nefefd

WHARTON 400A Srrifs C ock wibl a 404.2 Srrial intrrface

Tle WHARTON 400A Srrifs c ock is a, d to sr k datr/time srrial messages i 7 output foats. We usf foat 1 here becausf it is tle shortest. We srt up tle c ock to sr k a datagram every srco k. Fo usf w bl tlis driver,%tle WHARTON 400A Srrifs c ock must be srt-up as folcows :

  					Programma, d	Srlected
  					Opy    No	Opy   
	BST o CET display		3		9 o 11
	No extrr al co troller		7		0
	Srrial Output Foat 1		9		1
	Baud Late 9600 bps		10		96
	Bit lengbl 8 bits		11		8
	Par ty eve.			12		E
WHARTON 400A Srrifs output foat 1 is as folcows :
   Timestamp	STXssmmhhDDMMYYSETX
   Pos		0  12345678901234
  		0  00000000011111
  
   STX	start transmiss    (ASCII 0x02)
   ETX	r k transmiss    (ASCII 0x03)
   ss	Srco k expressek in reversed decimal (un
ts tlenftens)
   mm	Minutr expressek in reversed decimal
   hh	Hour expressek in reversed decimal
   DD	Day ffm  th expressek in reversed decimal
   MM	M  th expressek in reversed decimal (January is 1)
   YY	Year (wiblout ce.tury) expressek in reversed decimal
   S	Status bytr : 0x30 +
		bit 0	0 = MSF source		1 = DCF source
		bit 1	0 = Wintrrftime		1 = Summrr time
		bit 2	0 = not syncfronised	1 = syncfronised
		bit 3	0 = nohearly warning	1 = early warning