[ntp:bk-ntp-dev-send] BitKeeper diffs

Harlan Stenn stenn at whimsy.udel.edu
Sun Aug 17 23:47:38 UTC 2008


#### ChangeSet ####
2008-08-17 19:38:48-04:00, stenn at pogo.udel.edu 
  [Bug 1052] Add linuxPPS support to ONCORE driver

==== ChangeLog ====
2008-08-17 19:38:40-04:00, stenn at pogo.udel.edu +1 -0
  [Bug 1052] Add linuxPPS support to ONCORE driver

--- 1.208/ChangeLog	2008-08-17 07:51:51 -04:00
+++ 1.209/ChangeLog	2008-08-17 19:38:40 -04:00
@@ -1,3 +1,4 @@
+* [Bug 1052] Add linuxPPS support to ONCORE driver.
 (4.2.5p124) 2008/08/17 Released by Harlan Stenn <stenn at ntp.org>
 * Documentation updates from Dave Mills.
 * Include (4.2.4p5) 2008/08/17 Released by Harlan Stenn <stenn at ntp.org>

#### ChangeSet ####
2008-08-10 21:56:17-04:00, clemens at pogo.udel.edu 
  BUG[1052] Minor reordering of previous patch to make it more robust.

==== ntpd/refclock_oncore.c ====
2008-08-10 21:56:15-04:00, clemens at pogo.udel.edu +57 -58
  BUG[1052] Minor reordering of previous patch to make it more robust.

--- 1.60.1.5/ntpd/refclock_oncore.c	2008-08-10 18:31:11 -04:00
+++ 1.60.1.6/ntpd/refclock_oncore.c	2008-08-10 21:56:15 -04:00
@@ -299,55 +299,55 @@ struct instance {
 #define rcvbuf	instance->Rcvbuf
 #define rcvptr	instance->Rcvptr
 
-static	int	oncore_start	      P((int, struct peer *));
-static	void	oncore_poll	      P((int, struct peer *));
-static	void	oncore_shutdown       P((int, struct peer *));
-static	void	oncore_consume	      P((struct instance *));
-static	void	oncore_read_config    P((struct instance *));
-static	void	oncore_receive	      P((struct recvbuf *));
-static	int	oncore_ppsapi	      P((struct instance *));
-static	void	oncore_get_timestamp  P((struct instance *, long, long));
-static	void	oncore_init_shmem     P((struct instance *));
-
-static	void	oncore_antenna_report P((struct instance *, enum antenna_state));
-static	void	oncore_chan_test      P((struct instance *));
-static	void	oncore_check_almanac  P((struct instance *));
-static	void	oncore_check_antenna  P((struct instance *));
-static	void	oncore_check_leap_sec P((struct instance *));
-static	int	oncore_checksum_ok    P((u_char *, int));
-static	void	oncore_compute_dH     P((struct instance *));
-static	void	oncore_load_almanac   P((struct instance *));
-static	void	oncore_print_Cb       P((struct instance *, u_char *));
-/* static  void    oncore_print_array	 P((u_char *, int));	*/
-static	void	oncore_print_posn     P((struct instance *));
-static	void	oncore_sendmsg	      P((int, u_char *, size_t));
-static	void	oncore_set_posn       P((struct instance *));
-static	void	oncore_set_traim      P((struct instance *));
-static	void	oncore_shmem_get_3D   P((struct instance *));
-static	void	oncore_ss	      P((struct instance *));
-static	int	oncore_wait_almanac   P((struct instance *));
-
-static	void	oncore_msg_any	   P((struct instance *, u_char *, size_t, int));
-static	void	oncore_msg_Adef    P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Ag	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_As	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_At	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Ay	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Az	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_BaEaHa  P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Bd	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Bj	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_BnEnHn  P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_CaFaIa  P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Cb	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Cf	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Cj	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Cj_id   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Cj_init P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Ga	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Gb	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Gj	   P((struct instance *, u_char *, size_t));
-static	void	oncore_msg_Sz	   P((struct instance *, u_char *, size_t));
+static	int	oncore_start	      (int, struct peer *);
+static	void	oncore_poll	      (int, struct peer *);
+static	void	oncore_shutdown       (int, struct peer *);
+static	void	oncore_consume	      (struct instance *);
+static	void	oncore_read_config    (struct instance *);
+static	void	oncore_receive	      (struct recvbuf *);
+static	int	oncore_ppsapi	      (struct instance *);
+static	void	oncore_get_timestamp  (struct instance *, long, long);
+static	void	oncore_init_shmem     (struct instance *);
+
+static	void	oncore_antenna_report (struct instance *, enum antenna_state);
+static	void	oncore_chan_test      (struct instance *);
+static	void	oncore_check_almanac  (struct instance *);
+static	void	oncore_check_antenna  (struct instance *);
+static	void	oncore_check_leap_sec (struct instance *);
+static	int	oncore_checksum_ok    (u_char *, int);
+static	void	oncore_compute_dH     (struct instance *);
+static	void	oncore_load_almanac   (struct instance *);
+static	void	oncore_print_Cb       (struct instance *, u_char *);
+/* static  void    oncore_print_array	 (u_char *, int);	*/
+static	void	oncore_print_posn     (struct instance *);
+static	void	oncore_sendmsg	      (int, u_char *, size_t);
+static	void	oncore_set_posn       (struct instance *);
+static	void	oncore_set_traim      (struct instance *);
+static	void	oncore_shmem_get_3D   (struct instance *);
+static	void	oncore_ss	      (struct instance *);
+static	int	oncore_wait_almanac   (struct instance *);
+
+static	void	oncore_msg_any	   (struct instance *, u_char *, size_t, int);
+static	void	oncore_msg_Adef    (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Ag	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_As	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_At	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Ay	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Az	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_BaEaHa  (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Bd	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Bj	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_BnEnHn  (struct instance *, u_char *, size_t);
+static	void	oncore_msg_CaFaIa  (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Cb	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Cf	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Cj	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Cj_id   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Cj_init (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Ga	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Gb	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Gj	   (struct instance *, u_char *, size_t);
+static	void	oncore_msg_Sz	   (struct instance *, u_char *, size_t);
 
 struct	refclock refclock_oncore = {
 	oncore_start,		/* start up driver */
@@ -367,7 +367,7 @@ struct	refclock refclock_oncore = {
 static struct msg_desc {
 	const char	flag[3];
 	const int	len;
-	void		(*handler) P((struct instance *, u_char *, size_t));
+	void		(*handler) (struct instance *, u_char *, size_t);
 	const char	*fmt;
 	int		shmem;
 } oncore_messages[] = {
@@ -605,12 +605,18 @@ oncore_start(
 	     line discipline changed by another process.
 	*/
 
-	stat1.st_dev = stat1.st_ino = -1;
 	if (stat(device1, &stat1)) {
+		stat1.st_dev = stat1.st_ino = -1;
 		sprintf(Msg, "Can't stat fd1 (%s)\n", device1);
 		record_clock_stats(&(instance->peer->srcadr), Msg);
 	}
 
+	if (stat(device2, &stat2)) {
+		stat2.st_dev = stat2.st_ino = -2;
+		sprintf(Msg, "Can't stat fd2 (%s) errno = %d\n", device2, errno);
+		record_clock_stats(&(instance->peer->srcadr), Msg);
+	}
+
 	if (!(fd1 = refclock_open(device1, SPEED, LDISC_RAW))) {
 		sprintf(Msg, "Can't open fd1 (%s)\n", device1);
 		record_clock_stats(&(instance->peer->srcadr), Msg);
@@ -621,13 +627,6 @@ oncore_start(
 	   It seems simplest to let an external program create the appropriate
 	   /dev/pps<n> file, and only check (carefully) for its existance here
 	 */
-
-	stat2.st_dev = stat2.st_ino = -2;
-	if (stat(device2, &stat2)) {
-		sprintf(Msg, "Can't stat fd2 (%s) errno = %d\n", device2, errno);
-		record_clock_stats(&(instance->peer->srcadr), Msg);
-		record_clock_stats(&(instance->peer->srcadr), "May be line discipline, see if we can open it.");
-	}
 
 	if ((stat1.st_dev == stat2.st_dev) && (stat1.st_ino == stat2.st_ino))	/* same device here */
 		fd2 = fd1;

#### ChangeSet ####
2008-08-10 18:31:13-04:00, clemens at pogo.udel.edu 
  [BUG 1052] Modify ONCORE driver for linuxPPS which uses a line discipline for the
  PPS source.

==== ntpd/refclock_oncore.c ====
2008-08-10 18:31:11-04:00, clemens at pogo.udel.edu +21 -6
  [BUG 1052] Modify ONCORE driver for linuxPPS which uses a line discipline for the
  PPS source.

--- 1.60.1.4/ntpd/refclock_oncore.c	2008-08-10 18:21:30 -04:00
+++ 1.60.1.5/ntpd/refclock_oncore.c	2008-08-10 18:31:11 -04:00
@@ -594,24 +594,39 @@ oncore_start(
 	   Since things ALWAYS work if we only open the device once, we check
 	     to see if the two devices are in fact the same, then proceed to
 	     do one open or two.
+
+	   For use with linuxPPS we assume that the N_TTY file has been opened
+	     and that the line discipline has been changed to N_PPS by another
+	     program (say ppsldisc) so that the two files expected by the oncore
+	     driver can be opened.
+
+	   Note that the linuxPPS N_PPS file is just like a N_TTY, so we can do
+	     the stat below without error even though the file has already had its
+	     line discipline changed by another process.
 	*/
 
+	stat1.st_dev = stat1.st_ino = -1;
 	if (stat(device1, &stat1)) {
 		sprintf(Msg, "Can't stat fd1 (%s)\n", device1);
 		record_clock_stats(&(instance->peer->srcadr), Msg);
-		exit(1);
 	}
 
-	if (stat(device2, &stat2)) {
-		sprintf(Msg, "Can't stat fd2 (%s)\n", device2);
+	if (!(fd1 = refclock_open(device1, SPEED, LDISC_RAW))) {
+		sprintf(Msg, "Can't open fd1 (%s)\n", device1);
 		record_clock_stats(&(instance->peer->srcadr), Msg);
 		exit(1);
 	}
 
-	if (!(fd1 = refclock_open(device1, SPEED, LDISC_RAW))) {
-		sprintf(Msg, "Can't open fd1 (%s)\n", device1);
+	/* for LINUX the PPS device is the result of a line discipline.
+	   It seems simplest to let an external program create the appropriate
+	   /dev/pps<n> file, and only check (carefully) for its existance here
+	 */
+
+	stat2.st_dev = stat2.st_ino = -2;
+	if (stat(device2, &stat2)) {
+		sprintf(Msg, "Can't stat fd2 (%s) errno = %d\n", device2, errno);
 		record_clock_stats(&(instance->peer->srcadr), Msg);
-		exit(1);
+		record_clock_stats(&(instance->peer->srcadr), "May be line discipline, see if we can open it.");
 	}
 
 	if ((stat1.st_dev == stat2.st_dev) && (stat1.st_ino == stat2.st_ino))	/* same device here */

#### ChangeSet ####
2008-08-10 18:21:32-04:00, clemens at pogo.udel.edu 
  Remove unneeded variable.

==== ntpd/refclock_oncore.c ====
2008-08-10 18:21:30-04:00, clemens at pogo.udel.edu +2 -3
  Remove unneeded variable.

--- 1.60.1.3/ntpd/refclock_oncore.c	2008-08-10 18:18:54 -04:00
+++ 1.60.1.4/ntpd/refclock_oncore.c	2008-08-10 18:21:30 -04:00
@@ -531,7 +531,7 @@ oncore_start(
 #define STRING_LEN	32
 	register struct instance *instance;
 	struct refclockproc *pp;
-	int fd1, fd2, num;
+	int fd1, fd2;
 	char device1[STRING_LEN], device2[STRING_LEN], Msg[160];
 	const char *cp;
 	struct stat stat1, stat2;
@@ -623,11 +623,10 @@ oncore_start(
 			exit(1);
 		}
 	}
-	num = fd2;
 
 	/* open ppsapi soure */
 
-	if (time_pps_create(num, &instance->pps_h) < 0) {
+	if (time_pps_create(fd2, &instance->pps_h) < 0) {
 		record_clock_stats(&(instance->peer->srcadr), "PPSAPI not found in kernel");
 		return(0);
 	}

#### ChangeSet ####
2008-08-10 18:18:56-04:00, clemens at pogo.udel.edu 
  [BUG 1051] Month off by one in leap second message written to clockstats file, fixed.

==== ntpd/refclock_oncore.c ====
2008-08-10 18:18:54-04:00, clemens at pogo.udel.edu +1 -1
  [BUG 1051] Month off by one in leap second message written to clockstats file, fixed.

--- 1.60.1.2/ntpd/refclock_oncore.c	2007-11-01 02:29:21 -05:00
+++ 1.60.1.3/ntpd/refclock_oncore.c	2008-08-10 18:18:54 -04:00
@@ -2916,7 +2916,7 @@ oncore_msg_Gj(
 	if (dt) {
 		sprintf(Msg, "ONCORE[%d]: Leap second (%d) scheduled for %d%s%d at %d:%d:%d",
 			instance->unit,
-			dt, buf[9], Month[buf[8]], 256*buf[6]+buf[7],
+			dt, buf[9], Month[buf[8]-1], 256*buf[6]+buf[7],
 			buf[15], buf[16], buf[17]);
 		record_clock_stats(&(instance->peer->srcadr), Msg);
 	}


More information about the bk-ntp-dev-send mailing list