On Wed, Mar 14, 2007 at 04:47:32PM +0100, Rodolfo Giometti wrote:
> On Wed, Mar 14, 2007 at 11:37:05AM -0400, Lennart Sorensen wrote:
> > 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.
> 
> Thanks, published. :)

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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to