NetBSD Problem Report #10102

Received: (qmail 18577 invoked from network); 12 May 2000 06:55:20 -0000
Message-Id: <200005120655.e4C6tKt22133@capsicum.wsrcc.com>
Date: Thu, 11 May 2000 23:55:20 -0700 (PDT)
From: Wolfgang Rupprecht <wolfgang@wsrcc.com>
Reply-To: wolfgang@wsrcc.com
To: gnats-bugs@gnats.netbsd.org
Subject: pps api clear/assert inverted
X-Send-Pr-Version: 3.95

>Number:         10102
>Category:       kern
>Synopsis:       pps api clear/assert inverted
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 12 06:56:00 +0000 2000
>Closed-Date:    
>Last-Modified:  
>Originator:     Wolfgang Rupprecht
>Release:        NetBSD-current May 9,  2000
>Organization:
W S Rupprecht Computer Consulting, Fremont CA
>Environment:

System: NetBSD scoville.wsrcc.com 1.4Y NetBSD 1.4Y (WSRCC) #2: Tue May  9 17:00:21 PDT 2000     wolfgang@capsicum.wsrcc.com:/v/src/netbsd/NetBSD-current/usr/src/sys/arch/i386/compile/WSRCC i386

>Description:

	the PPS (pulse per second) api signals are reversed.  The
	PPS_CAPTUREASSERT event is monitored and flagged as a
	PPS_CAPTURECLEAR event and visa versa.

>How-To-Repeat:

    run ntp from a known good source.  Let the clocks sync up for 
    10 minutes.  Ntp is none too speedy about this. 

    compile the following program.  hook up a PPS clock that 
    asserts the signal on the second and clears the signal 200 ms
    later.  (I'm using a motorola oncore M12 oem board).

    Notice that the assertion is at ~200ms after the second.
    Notice that the clear is at the even second.

    Shamelessly stolen from the RFC:

    #include <stdio.h>
    #include <unistd.h>
    #include <ctype.h>
    #include <sys/types.h>
    #include <sys/time.h>
    #include <sys/stat.h>

    #include <sys/timepps.h>

    /* 
     * Mogul, et al.                Informational                     [Page 22]
     *
     * RFC 2783                  Pulse-Per-Second API                March 2000
     */

    void
    pps(int fd, char * PPSfilename)
    {
	  pps_handle_t handle;
	  pps_params_t params;
	  pps_info_t infobuf;
	  int avail_mode;
	  struct timespec timeout;

	  time_pps_create(fd, &handle);

	  /*
	   * Find out what features are supported
	   */

	  time_pps_getcap(handle, &avail_mode);
	  if ((avail_mode & PPS_CAPTUREASSERT) == 0) {
	      fprintf(stderr, "%s cannot CAPTUREASSERT\n", PPSfilename);
	      exit(1);
	  }
	  if ((avail_mode & PPS_OFFSETASSERT) == 0) {
	      fprintf(stderr, "%s cannot OFFSETASSERT\n", PPSfilename);
	      exit(1);
	  }

	  /*
	   * Capture assert timestamps
	   */

	  time_pps_getparams(handle, &params);
	  params.assert_offset.tv_sec = 0;
	  params.assert_offset.tv_nsec = 0;
	  params.mode |= PPS_CAPTUREBOTH;
	  time_pps_setparams(handle, &params);


	  /* create a zero-valued timeout */
	  timeout.tv_sec = 0;
	  timeout.tv_nsec = 0;

	  /* loop, printing the most recent timestamp every second or so */
	  while (1) {
	      if (avail_mode & PPS_CANWAIT) {
		  time_pps_fetch(handle, PPS_TSFMT_TSPEC, &infobuf, NULL);
				  /* waits for the next event */
	      } else {
		  sleep(1);
		  time_pps_fetch(handle, PPS_TSFMT_TSPEC, &infobuf,
		    &timeout);

	      }

	      printf("Assert timestamp: %d.%09d, sequence: %ld\n",
			  infobuf.assert_timestamp.tv_sec,
			  infobuf.assert_timestamp.tv_nsec,
			  infobuf.assert_sequence);

	      printf(" Clear timestamp: %d.%09d, sequence: %ld\n",
			  infobuf.clear_timestamp.tv_sec,
			  infobuf.clear_timestamp.tv_nsec,
			  infobuf.clear_sequence);
	  }
    }

>Fix:
	I think the fix is as simple as throwing an inversion in where
	the DCD hardware line is tested.
>Release-Note:
>Audit-Trail:
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.