On Wed, Mar 14, 2007 at 04:57:32PM -0400, Lennart Sorensen 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.

Can you please provide a little help about it? A patch against current
wiki wuold be great! ;)

> 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).

I modify your code add inquiry functionality. Can you please test it?

See http://ftp.enneenne.com/pub/misc/linuxpps/test/ and the wiki at
http://wiki.enneenne.com/index.php/LinuxPPS_support#Compiling_the_code.

Ciao,

Rodolfo

-- 

GNU/Linux Solutions                  e-mail:    [EMAIL PROTECTED]
Linux Device Driver                             [EMAIL PROTECTED]
Embedded Systems                                [EMAIL PROTECTED]
UNIX programming                     phone:     +39 349 2432127
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <linux/serial.h>

void usage(char *name)
{
        fprintf(stderr, "usage: %s <ttyS> [enable|disable]\n", name);

	exit(EXIT_FAILURE);
}

int main(int argc, char *argv[])
{
	int fd, ret;
	struct serial_struct  ss;

	if (argc < 2)
		usage(argv[0]);

        fd = open(argv[1], O_RDWR);
        if (fd < 0) {
                perror("open");
		exit(EXIT_FAILURE);
	}

       	ret = ioctl(fd, TIOCGSERIAL, &ss);
	if (ret < 0 ) {
		perror("ioctl(TIOCGSERIAL)");
		exit(EXIT_FAILURE);
	}

	if (argc < 3) {		/* just read PPS status */
		printf("PPS is %sabled\n",
			ss.flags & ASYNC_HARDPPS_CD ? "en" : "dis");
		exit(EXIT_SUCCESS);
	}

	if (argv[2][0] == 'e' || argv[2][0] == '1')
		ss.flags |= ASYNC_HARDPPS_CD;
	else if (argv[2][0] == 'd' || argv[2][0] == '0')
		ss.flags &= ~ASYNC_HARDPPS_CD;
	else {
		fprintf(stderr, "invalid state argument \"%s\"\n", argv[2]);
		exit(EXIT_FAILURE);
	} 

	ret = ioctl(fd, TIOCSSERIAL, &ss);
	if (ret < 0) {
		perror("ioctl(TIOCSSERIAL)");
		exit(EXIT_FAILURE);
	}

        return 0;
}

Reply via email to