Replied: Fri, 01 May 1998 11:31:45 -0400
Replied: "Per Hedeland <per@erix.ericsson.se> "
Received: from mail.eecis.udel.edu by whimsy.udel.edu id aa06670;
          1 May 1998 08:09 EDT
Received: from super.du.etx.ericsson.se (per@super.du.etx.ericsson.se [150.236.14.16]) by penguin.wise.edt.ericsson.se (8.7.5/8.7.3/penguin-1.12) with ESMTP id OAA11002 for <stenn@whimsy.udel.edu>; Fri, 1 May 1998 14:09:56 +0200 (MET DST)
Received: (from per@localhost)
	by super.du.etx.ericsson.se (8.9.0.Beta6/8.9.0.Beta6/erix-1.4) id OAA03368;
	Fri, 1 May 1998 14:09:56 +0200 (MET DST)
Date: Fri, 1 May 1998 14:09:56 +0200 (MET DST)
From: Per Hedeland <per@erix.ericsson.se>
Message-Id: <199805011209.OAA03368@super.du.etx.ericsson.se>
To: stenn@whimsy.udel.edu
Subject: Re: xntp3-5.93 has been released.
Newsgroups: comp.protocols.time.ntp
In-Reply-To: <o4wwca7v67.fsf@whimsy.udel.edu>

In article <o4wwca7v67.fsf@whimsy.udel.edu> you write:
>Again, we will limit changes to portability and bugs only.

>* Jupiter clock added

Well, I don't know whether this was portability or bug:-) (or perhaps
that policy wasn't applied before), but anyway it breaks compilation
on Solaris 2.6 when PPS is #defined (I just recently figured out how to
use the PPS support in Solaris 2.6 with ATOM - without source changes to
xntp):

refclock_jupiter.c: In function `jupiter_ttyinit':
refclock_jupiter.c:1305: `pps_enable' undeclared (first use in this function)
refclock_jupiter.c:1305: (Each undeclared identifier is reported only once
refclock_jupiter.c:1305: for each function it appears in.)
*** Error code 1

Adding the missing declaration is trivial of course, but whether that
makes the code "correct" is another question - it seems to me that the
#ifdef's guarding the two ioctl's towards the end don't really represent
the appropriate logic - certainly both TIOCSPPS and I_PUSH are #defined
on Solaris 2.6, for example, while it seems unlikely that both ioctl's
should be done. (Of course running configure with --disable-JUPITER is a
possible workaround for the problem.)

Another thing, which you may or may not consider a "bug" worth fixing in
xntp3 (sorry, I haven't looked at version 4 yet): It isn't possible to
use LDISC_PPS if you *only* have the PPS-via-DCD signal (i.e. no
timestamp data coming via the same serial port to be consumed by another
clock driver) - I recently had a need for this as I wanted to feed the
PPS signal to two computers, while only one received the associated
timestamp (feeding this to both would have been complex as xntpd polls
the clock - Arbiter).

Now, refclock_atom.c has code to deal with the situation that there is
no other driver opening the serial port, and will open it itself after a
short delay - but when doing so, unconditionally uses LDISC_CLKPPS for
no apparent (to me:-) reason. The very small change below will (obviously)
make it use LDISC_PPS instead if PPS is #defined.

I'm pretty sure this change is "safe", as PPS being #defined implies
usage of LDISC_PPS in lots of other places in the code - e.g. atom_pps()
will keep polling the port using CIOGETEV, which is inappropriate when
it was opened with LDISC_CLKPPS. Of course some of the comments will no
longer agree with the code, but I'd be happy to fix that up too if you
decide to include the change.

--Per Hedeland
per@erix.ericsson.se


*** xntpd/refclock_atom.c.orig	Sat Apr 25 01:14:20 1998
--- xntpd/refclock_atom.c	Wed Apr 29 14:41:20 1998
***************
*** 456,462 ****
  			 */
  			(void)sprintf(device, DEVICE, unit);
  			if (!(fd = refclock_open(device, SPEED232,
! 	 		    LDISC_CLKPPS))) {
  				refclock_report(peer, CEVNT_FAULT);
  				return;
  			}
--- 456,467 ----
  			 */
  			(void)sprintf(device, DEVICE, unit);
  			if (!(fd = refclock_open(device, SPEED232,
! #ifdef PPS
! 	 		    LDISC_PPS
! #else
! 	 		    LDISC_CLKPPS
! #endif
! 			    ))) {
  				refclock_report(peer, CEVNT_FAULT);
  				return;
  			}

