All of lore.kernel.org
 help / color / mirror / Atom feed
From: lsorense@csclub.uwaterloo.ca (Lennart Sorensen)
To: Rodolfo Giometti <giometti@enneenne.com>
Cc: linux-kernel@vger.kernel.org, linuxpps@ml.enneenne.com,
	Russell King <rmk+lkml@arm.linux.org.uk>,
	Jan Dittmer <jdi@l4x.org>, Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux
Date: Wed, 14 Mar 2007 11:37:05 -0400	[thread overview]
Message-ID: <20070314153705.GP22464@csclub.uwaterloo.ca> (raw)
In-Reply-To: <20070314145239.GK3802@enneenne.com>

Well here is my current version of the refclock_nmea.c.patch for
LinuxPPS.  It now uses /dev/gps# for the nmea messages and /dev/pps# for
the PPS device (which in my case is of course the same device).  I am
running some more tests on it, but I think it is OK.

--- refclock_nmea.c.ori	2007-03-14 11:24:14.000000000 -0400
+++ refclock_nmea.c	2007-03-14 11:31:04.000000000 -0400
@@ -69,6 +69,7 @@
 # define DEVICE "COM%d:" 	/* COM 1 - 3 supported */
 #else
 # define DEVICE	"/dev/gps%d"	/* name of radio device */
+# define PPSDEVICE	"/dev/pps%d"	/* name of pps device */
 #endif
 #define	SPEED232	B4800	/* uart speed (4800 bps) */
 #define	PRECISION	(-9)	/* precision assumed (about 2 ms) */
@@ -79,6 +80,7 @@
 #define RANGEGATE	500000	/* range gate (ns) */
 
 #define LENNMEA		75	/* min timecode length */
+#define LENPPS		PPS_MAX_NAME_LEN
 
 /*
  * Tables to compute the ddd of year form icky dd/mm timecode. Viva la
@@ -99,6 +101,7 @@
 	pps_params_t pps_params; /* pps parameters */
 	pps_info_t pps_info;	/* last pps data */
 	pps_handle_t handle;	/* pps handlebars */
+	int handle_created;	/* pps handle created flag */
 #endif /* HAVE_PPSAPI */
 };
 
@@ -147,6 +150,11 @@
 	register struct nmeaunit *up;
 	struct refclockproc *pp;
 	int fd;
+#ifdef PPS_HAVE_FINDPATH
+	char id[LENPPS] = "",
+	     path[LENPPS],
+	     ppsdevice[LENPPS] = "";    /* just a default device */
+#endif	/* PPS_HAVE_FINDPATH */
 	char device[20];
 
 	/*
@@ -238,12 +246,26 @@
 	 * Start the PPSAPI interface if it is there. Default to use
 	 * the assert edge and do not enable the kernel hardpps.
 	 */
+#ifdef PPS_HAVE_FINDPATH
+	/* Get the PPS source's real name */
+	(void)sprintf(ppsdevice, PPSDEVICE, unit);
+	time_pps_readlink(ppsdevice, LENPPS, path, LENPPS);
+
+	/* Try to find the source */
+	fd = time_pps_findpath(path, LENPPS, id, LENPPS);
+	if (fd < 0) {
+		msyslog(LOG_ERR, "refclock_nmea: cannot find PPS path \"%s\" in the system", path);
+		return (0);
+	}
+	msyslog(LOG_INFO, "refclock_nmea: found PPS source \"%s\" at id #%d on \"%s\"", path, fd, id);
+#endif	/* PPS_HAVE_FINDPATH */
 	if (time_pps_create(fd, &up->handle) < 0) {
-		up->handle = 0;
+		up->handle_created = 0;
 		msyslog(LOG_ERR,
 		    "refclock_nmea: time_pps_create failed: %m");
 		return (1);
 	}
+	up->handle_created = ~0;
 	return(nmea_ppsapi(peer, 0, 0));
 #else
 	return (1);
@@ -265,8 +287,10 @@
 	pp = peer->procptr;
 	up = (struct nmeaunit *)pp->unitptr;
 #ifdef HAVE_PPSAPI
-	if (up->handle != 0)
+	if (up->handle_created) {
 		time_pps_destroy(up->handle);
+		up->handle_created = 0;
+	}
 #endif /* HAVE_PPSAPI */
 	io_closeclock(&pp->io);
 	free(up);
@@ -374,7 +398,7 @@
 	/*
 	 * Convert the timespec nanoseconds field to ntp l_fp units.
 	 */ 
-	if (up->handle == 0)
+	if (!up->handle_created)
 		return (0);
 	timeout.tv_sec = 0;
 	timeout.tv_nsec = 0;

--
Len Sorensen

  reply	other threads:[~2007-03-14 15:37 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-16 18:52 [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux Rodolfo Giometti
2007-02-16 19:12 ` Russell King
2007-02-16 20:43   ` Rodolfo Giometti
2007-02-16 20:51     ` Russell King
2007-02-16 21:03       ` Rodolfo Giometti
2007-02-16 19:56 ` Jan Dittmer
2007-02-16 20:57   ` Rodolfo Giometti
2007-02-16 21:19     ` Jan Dittmer
2007-02-18 22:43 ` LinuxPPS: fixes Rodolfo Giometti
2007-02-20  2:56 ` [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux H. Peter Anvin
2007-02-21 12:04   ` Rodolfo Giometti
2007-02-21 16:14     ` H. Peter Anvin
2007-02-22  8:51       ` Rodolfo Giometti
2007-02-21 23:51     ` Roman Zippel
2007-02-22  9:00       ` Rodolfo Giometti
2007-02-21 10:16 ` Pavel Machek
2007-02-22  9:59   ` Rodolfo Giometti
2007-03-13 21:38 ` Rodolfo Giometti
2007-03-13 22:48   ` Lennart Sorensen
2007-03-14  9:31     ` Rodolfo Giometti
2007-03-14 13:19       ` Lennart Sorensen
2007-03-14 14:06         ` Rodolfo Giometti
2007-03-14 14:12           ` Lennart Sorensen
2007-03-14 14:27             ` Rodolfo Giometti
2007-03-14 14:42               ` Lennart Sorensen
2007-03-14 14:52                 ` Rodolfo Giometti
2007-03-14 15:37                   ` Lennart Sorensen [this message]
2007-03-14 15:47                     ` Rodolfo Giometti
2007-03-14 20:57                       ` Lennart Sorensen
2007-03-15 10:29                         ` Rodolfo Giometti
2007-03-15 15:18                           ` Lennart Sorensen
2007-03-15 15:37                             ` Rodolfo Giometti
2007-03-21  7:41 Rodolfo Giometti
2007-03-21  8:05 ` Jon K Hellan
2007-03-21  8:08   ` Rodolfo Giometti
2007-03-21 15:34   ` Lennart Sorensen
2007-05-02 19:33 ` Rodolfo Giometti
2007-05-02 21:06   ` john stultz
2007-05-03 10:03     ` Rodolfo Giometti
2007-05-10  7:27   ` Andrew Morton
2007-05-10  9:48     ` Andrew Morton
2007-05-10 10:58     ` Rodolfo Giometti
2007-05-10 11:01       ` David Miller
2007-05-10 11:45         ` Rodolfo Giometti
2007-05-10 11:51           ` David Miller
2007-05-10 11:54             ` David Miller
2007-05-12  5:59     ` Rodolfo Giometti
2007-05-12  6:17       ` Andrew Morton
2007-05-12  7:08         ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070314153705.GP22464@csclub.uwaterloo.ca \
    --to=lsorense@csclub.uwaterloo.ca \
    --cc=giometti@enneenne.com \
    --cc=jdi@l4x.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxpps@ml.enneenne.com \
    --cc=pavel@ucw.cz \
    --cc=rmk+lkml@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.