RPC modul pro synchronizaci casu

Vitezslav Samel vitezslav na samel.cz
Středa Červenec 9 07:30:50 CEST 2008


On Tue, Jul 08, 2008 at 12:18:52AM +0200, Jan Krajdl wrote:
> > 	Ahoj!
> > 
> >   Neco takoveho tu mam a mel jsem to funkcni (ted uz ne, na presny cas
> > mam GPS).
> > 
> >   Software: ntpd (ovladac je PARSE, v konfigu jsem mel
> >                   "server 127.127.8.1 mode 16")
> > 
> 
> Tak jsem si s tím teď hrál, ale čas se nesyncnul... LEDka zhasne,
> takže zjevně nějaká komunikace na portu je, módy jsem vystřídal od 0
> do 20ti, ale nesyncuje to ani na jednom :( Dá se tam laborovat s těma
> parametrama ještě nějak nebo mám smolíka?

  Hmm, tak koukam, ze jsem jeste delal nejake upravy ntpd kodu, aby to
behalo (napajeni toho udelatka se zapina jinymi piny RS232 portu).

	Vita


diff -urpN ntp-4.2.4.orig/libparse/clk_rawdcf.c ntp-4.2.4/libparse/clk_rawdcf.c
--- ntp-4.2.4.orig/libparse/clk_rawdcf.c	2006-06-25 13:02:18.000000000 +0200
+++ ntp-4.2.4/libparse/clk_rawdcf.c	2007-03-01 08:32:44.000000000 +0100
@@ -234,7 +234,7 @@ convert_rawdcf(
 	if (size < 57)
 	{
 #ifndef PARSEKERNEL
-		msyslog(LOG_ERR, "parse: convert_rawdcf: INCOMPLETE DATA - time code only has %d bits\n", size);
+		parseprintf(DD_RAWDCF,("parse: convert_rawdcf: INCOMPLETE DATA - time code only has %d bits\n", size));
 #endif
 		return CVT_NONE;
 	}
@@ -247,7 +247,7 @@ convert_rawdcf(
 			 * we only have two types of bytes (ones and zeros)
 			 */
 #ifndef PARSEKERNEL
-			msyslog(LOG_ERR, "parse: convert_rawdcf: BAD DATA - no conversion");
+			parseprintf(DD_RAWDCF, ("parse: convert_rawdcf: BAD DATA - no conversion"));
 #endif
 			return CVT_NONE;
 		}
@@ -320,7 +320,7 @@ convert_rawdcf(
 		 * bad format - not for us
 		 */
 #ifndef PARSEKERNEL
-		msyslog(LOG_ERR, "parse: convert_rawdcf: parity check FAILED for \"%s\"\n", buffer);
+		parseprintf(DD_RAWDCF, ("parse: convert_rawdcf: parity check FAILED for \"%s\"\n", buffer));
 #endif
 		return CVT_FAIL|CVT_BADFMT;
 	}
diff -urpN ntp-4.2.4.orig/parseutil/dcfd.c ntp-4.2.4/parseutil/dcfd.c
--- ntp-4.2.4.orig/parseutil/dcfd.c	2006-12-28 13:03:59.000000000 +0100
+++ ntp-4.2.4/parseutil/dcfd.c	2007-03-01 08:32:44.000000000 +0100
@@ -875,7 +875,7 @@ type(
      )
 {
 	c ^= 0xFF;
-	return (c > 0xF);
+	return (c >= 0xF);
 }
 
 /*-----------------------------------------------------------------------
@@ -1364,6 +1364,7 @@ check_y2k( void )
 /*--------------------------------------------------
  * rawdcf_init - set up modem lines for RAWDCF receivers
  */
+#include <sys/ioctl.h>
 #if defined(TIOCMSET) && (defined(TIOCM_DTR) || defined(CIOCM_DTR))
 static void
 rawdcf_init(
@@ -1376,18 +1377,18 @@ rawdcf_init(
 	 * the name has changed from CIOCM_DTR to TIOCM_DTR recently.
 	 */
 	
-#ifdef TIOCM_DTR
-	int sl232 = TIOCM_DTR;	/* turn on DTR for power supply */
-#else
-	int sl232 = CIOCM_DTR;	/* turn on DTR for power supply */
-#endif
+	int sl232 = TIOCM_DTR;	/* turn on RTS for power supply */
 
+	if (ioctl(fd, TIOCMGET, (caddr_t)&sl232) == -1)
+		syslog(LOG_NOTICE, "rawdcf_init: WARNING: ioctl(fd, TIOCMGET, [C|T]IOCM_RTS): %m");
+	sl232 = (sl232 & ~TIOCM_DTR) | TIOCM_RTS;
 	if (ioctl(fd, TIOCMSET, (caddr_t)&sl232) == -1)
 	{
-		syslog(LOG_NOTICE, "rawdcf_init: WARNING: ioctl(fd, TIOCMSET, [C|T]IOCM_DTR): %m");
+		syslog(LOG_NOTICE, "rawdcf_init: WARNING: ioctl(fd, TIOCMSET, [C|T]IOCM_RTS): %m");
 	}
 }
 #else
+#error error
 static void
 rawdcf_init(
 	    int fd
diff -urpN ntp-4.2.4.orig/parseutil/testdcf.c ntp-4.2.4/parseutil/testdcf.c
--- ntp-4.2.4.orig/parseutil/testdcf.c	2006-06-06 22:17:05.000000000 +0200
+++ ntp-4.2.4/parseutil/testdcf.c	2007-03-01 08:32:44.000000000 +0100
@@ -41,6 +41,7 @@
 #include <stdio.h>
 #include <fcntl.h>
 #include <termios.h>
+#include <sys/ioctl.h>
 
 /*
  * state flags
@@ -363,8 +364,8 @@ main(
 		else
 		{
 			int i;
-#ifdef TIOCM_RTS
-			int on = TIOCM_RTS;
+#ifdef TIOCM_DTR
+			int on = TIOCM_DTR;
 #endif
 			struct timeval t, tt, tlast;
 			char buf[61];



Další informace o konferenci Linux