Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Lennart Sorensen
Date: Wednesday, March 14, 2007 - 1:57 pm

On Wed, Mar 14, 2007 at 04:47:32PM +0100, Rodolfo Giometti wrote:

Well it does work for our GPS receiver at least.  Of course I have to
change the baud rate in the driver since our unit doens't use the NNEA
standard 4800.  And the configure script for ntp doesn't recognize the
v2 PPSAPI, so I have to manually explain to it that I have the PPS API
and it should actually include it.

Here is my utility for enabling PPS on my serial port now.  Seems less
of a pain that patching setserial and including that (with 256MB flash
space, setserial seems wasteful).

ppsctl.c
--------
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <linux/serial.h>

void usage(char *name) {
	fprintf(stderr,"Usage: %s /dev/port [0|1]\n",name);
	fprintf(stderr,"Where 0 means disable PPS and 1 means enable PPS\n");
}

int main(int argc, char *argv[]) {
	int fd;
	char *state;

	if(argc<3) {
		usage(argv[0]);
		return 1;
	}
	fd = open(argv[1],O_RDWR);
	if (fd>=0) {
		struct serial_struct  ss;
		if (ioctl(fd, TIOCGSERIAL, &ss) < 0 ) {
			perror("TIOCGSERIAL");
			return 1;
		} else {
			if(strcmp(argv[2],"1")==0) {
				ss.flags |= ASYNC_HARDPPS_CD;
				state="enabled";
			} else if(strcmp(argv[2],"0")==0) {
				ss.flags &= ~ASYNC_HARDPPS_CD;
				state="disabled";
			} else {
				fprintf(stderr,"Invalid state argument \"%s\"\n",argv[2]);
				return 1;
			}
			if (ioctl(fd, TIOCSSERIAL, &ss) < 0) {
				perror("TIOCSSERIAL");
			} else {
				fprintf(stderr,"PPS on %s is now %s\n",argv[1],state);
			}
		}
	} else {
		fprintf(stderr,"Can't open \"%s\":",argv[1]);
		perror("");
	}
	return 0;
}

/* vim:ts=4:shiftwidth=4:
 * */

--
Len Sorensen
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Fri Feb 16, 11:52 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Fri Feb 16, 1:43 pm)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Fri Feb 16, 1:57 pm)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Fri Feb 16, 2:03 pm)
LinuxPPS: fixes, Rodolfo Giometti, (Sun Feb 18, 3:43 pm)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Wed Feb 21, 5:04 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Thu Feb 22, 1:51 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Thu Feb 22, 2:00 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Thu Feb 22, 2:59 am)
[PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Tue Mar 13, 2:38 pm)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Lennart Sorensen, (Tue Mar 13, 3:48 pm)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Wed Mar 14, 2:31 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Lennart Sorensen, (Wed Mar 14, 6:19 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Wed Mar 14, 7:06 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Lennart Sorensen, (Wed Mar 14, 7:12 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Wed Mar 14, 7:27 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Lennart Sorensen, (Wed Mar 14, 7:42 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Wed Mar 14, 7:52 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Lennart Sorensen, (Wed Mar 14, 8:37 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Wed Mar 14, 8:47 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Lennart Sorensen, (Wed Mar 14, 1:57 pm)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Thu Mar 15, 3:29 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Lennart Sorensen, (Thu Mar 15, 8:18 am)
Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux, Rodolfo Giometti, (Thu Mar 15, 8:37 am)