gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-users] ppsthread.c broken for FreeBSD gpio


From: Tony Hain
Subject: Re: [gpsd-users] ppsthread.c broken for FreeBSD gpio
Date: Mon, 13 Mar 2017 14:35:17 -0700

Digging into this further ...

> -----Original Message-----
> From: gpsd-users [mailto:address@hidden
> On Behalf Of Tony Hain
> Sent: Friday, March 10, 2017 11:52 AM
> To: address@hidden
> Subject: [gpsd-users] ppsthread.c broken for FreeBSD gpio
> 
> The "non-linux" code in ppsthread.c is designed to fail in the case of gpio on
> FreeBSD. The discussion below was on the ntpsec list, but fixing gpsd clearly
> belongs here.
> 
> > -----Original Message-----
> > From: bugs [mailto:address@hidden On Behalf Of Gary E.
> > Miller
> > Sent: Friday, March 10, 2017 9:53 AM
> > To: address@hidden
> > Subject: Re: nmea refclock not locking to the pps
> ...
> > On Thu, 9 Mar 2017 22:33:36 -0800
> > "Tony Hain" <address@hidden> wrote:
> >
> > > Following up with a patch :::
> > >
> > > ...
> > >
> > > I patched ppsthread.c, and I am sure this is not the correct way to
> > > do this since I have not been able to follow the overall structure,
> > > but it does appear to have opened the api.
> > >
> > > ppsthread.c -
> > > ...
> > > #else /* not __linux__ */
> > >     /*
> > >      * On BSDs that support RFC2783, one uses the API calls on serial
> > >      * port file descriptor.
> > >      *
> > >      * FIXME! need more specific than 'not linux'
> > >      */
> > > // inserting if test for /dev/pps name
> > >     if (strncmp(pps_thread->devicename, "/dev/pps", 8) == 0) {
> > >         ret = open(pps_thread->devicename, O_RDWR);
> > >     } else {       // existing
> > >
> > >     (void)strlcpy(path, pps_thread->devicename, sizeof(path));
> > >     // cppcheck-suppress redundantAssignment
> > >     ret  = pps_thread->devicefd;
> > >
> > >     }
> > > //
> > > #endif
> > > // inserting error check for non-linux (makes test in linux block
> > > redundant) if ( 0 > ret ) {
> > >         char errbuf[BUFSIZ] = "unknown error";
> > >         (void)strerror_r(errno, errbuf, sizeof(errbuf));
> > >         pps_thread->log_hook(pps_thread, THREAD_INF,
> > >                 "KPPS:%s running as %d/%d, cannot open %s: %s\n",
> > >                 pps_thread->devicename,
> > >                 getuid(), geteuid(),
> > >                 path, errbuf);
> > >         return -1;
> > >     } else {        // existing
> > >
> > >     /* assert(ret >= 0); */
> > >     pps_thread->log_hook(pps_thread, THREAD_INF,
> > >                 "KPPS:%s RFC2783 path:%s, fd is %d\n",
> > >                 pps_thread->devicename, path,
> > >                 ret);
> > >
> > >     }
> > > //
> > >     /* RFC 2783 implies the time_pps_setcap() needs priviledges * ...
> > >
> > > # grep KPPS /var/log/messages
> > > Mar  9 20:53:59 tic gpsd[67512]: gpsd:INFO: KPPS:/dev/pps1 RFC2783
> > > path:, fd is 7 Mar  9 20:53:59 tic gpsd[67512]: gpsd:INFO:
> > > KPPS:/dev/pps1 pps_caps
> > > 0x1111 Mar  9 20:53:59 tic gpsd[67512]:
> > > gpsd:INFO: KPPS:/dev/pps1 have PPS_CANWAIT  Mar  9 20:53:59 tic
> > > gpsd[67512]: gpsd:WARN: KPPS:/dev/pps1 missing PPS_CAPTURECLEAR,
> > > pulse may be offset Mar  9 20:53:59 tic gpsd[67512]: gpsd:INFO:
> > > KPPS:/dev/pps1 kernel PPS will be used Mar  9 20:53:59 tic
> > > gpsd[67512]: gpsd:PROG: KPPS:/dev/pps1
> > > gps_fd:-2 not a tty, can not use TIOMCIWAIT Mar 10 04:54:00 tic
> > > gpsd[67512]: gpsd:PROG: KPPS:/dev/pps1 assert
> > > 1489121640.028303412, sequence: 693997,clear   0.000000000,
> > > sequence: 0 - using: assert
> > > Mar 10 04:54:00 tic gpsd[67512]: gpsd:PROG: KPPS:/dev/pps1
> > > Assert cycle: 1489121640028303, duration:       0 @  1489121640.028303412
> > > Mar 10 04:54:01 tic gpsd[67512]: gpsd:PROG: KPPS:/dev/pps1 assert
> > > 1489121641.027803327, sequence: 693998, clear   0.000000000,
> > > sequence: 0 - using: assert
> > > Mar 10 04:54:01 tic gpsd[67512]:gpsd:PROG: KPPS:/dev/pps1
> > > Assert cycle:  999499, duration:       0 @ 1489121641.027803327
> > >
> > >
> > > I am getting log events above that the api is open,  and ntpshmmon
> > > shows the pps events now, but the ntpsec.conf refclock line is not
> > > recognizing the shm pps device.
> > >
> > > # ntpshmmon
> > > ntpshmmon version 1
> > > #      Name Seen@                Clock
> > > Real                 L Prec
> > > sample NTP0 1489124430.611470658 1489124430.412209171
> > > 1489124430.000000000 0 -20
> > > sample NTP2 1489124430.611553695 1489124428.000033371
> > > 1489124428.000000000 0 -30
> > > sample NTP0 1489124431.412239685 1489124431.411282520
> > > 1489124431.000000000 0 -20
> > > sample NTP2 1489124432.001544155 1489124432.000033265
> > > 1489124432.000000000 0 -30
> > > sample NTP0 1489124432.415040281 1489124432.413955830
> > > 1489124432.000000000 0 -20
> > > sample NTP2 1489124433.002155059 1489124433.000033281
> > > 1489124433.000000000 0 -30
> > > sample NTP0 1489124433.411896022 1489124433.411793694
> > > 1489124433.000000000 0 -20
> > > sample NTP2 1489124434.002308776 1489124434.000033212
> > > 1489124434.000000000 0 -30

So the reason that the pps is being ignored is that the edge detection code is 
also linux specific (though I haven't traced it all yet), in that it knows how 
to deal with a linux Rpi with a single edge pps, but this being FreeBSD, it 
assumes both edges exist, then rejects the results. I have hacked it to force 
the edge dector to buy in, but before it gets there the invisible flag is set 
and other logic gives up on it.

Mar 13 21:24:22 tic gpsd[76642]: gpsd:RAW: PPS:/dev/pps0 Assert pps-detect 
invisible pulse


Looking at the code, my pulse shaper/driver for the MR350p would likely fail 
anyway because it is 530/470ms, and this appears to want the assert state to be 
shorter than 90% of half (which likely explains why I have never had any luck 
getting gpsd to play nice with ntp). It would be easy enough to customize the 
width detection part of this, but that part doesn't matter if it is rejected 
elsewhere. There are Rpi specific values referenced for dealing with its 
assert-only linux behavior, so the assumption that single-edge is Rpi-only 
would be at fault.

Tony


> > >
> > > # ntpmon
> > >   remote  refid   st t when poll reach   delay offset   jitter
> > > xSHM(0)  .GPS.  0  l  2  64  377  0.0000  33.9512  2.4540
> > >   SHM(1)  .PPS.  0  l  -   4    0  0.0000  0.0000  0.0000
> > > *2001:470:e930:2 .PPS.  1  u   33  64 377 0.9863  -0.3318 0.1757
> > > +express.tndh.ne .GPS.  1  u  39  64 377 1.2442 -0.2851 1.6407
> > > +trail.tndh.net  .GPS.  1 u  36   64  377 1.1138 -0.2766 0.1899
> > > ntpd ntpsec-0.9.6+536 2017-02-22T20:26:50Z
> > >   Last update: 2017-03-09T21:13:30
> > >
> > > # grep ^refclock /etc/ntp.conf
> > > refclock shm unit 0 refid GPS time1 0.4429166667 refclock shm unit 1
> > > refid PPS prefer minpoll 2 maxpoll 2 time1 0.000000337160
> ---
> 
> Tony





reply via email to

[Prev in Thread] Current Thread [Next in Thread]