gpsd-dev
[Top][All Lists]
Advanced

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

Re: [gpsd-dev] U-Blox M8, PPS and NTPsec - GPSd logic enhancement


From: Martin Boissonneault
Subject: Re: [gpsd-dev] U-Blox M8, PPS and NTPsec - GPSd logic enhancement
Date: Sat, 6 Apr 2019 02:02:50 -0400
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

Hi Gary,

On 2019-04-05 19:40, Gary E. Miller wrote:
Yo Martin!

On Fri, 5 Apr 2019 18:52:23 -0400
Martin Boissonneault <address@hidden> wrote:

So: what is your current ntp.conf,  
[...]
# LAN servers:
server 192.168.10.10 iburst maxpoll 5
server 192.168.10.11 iburst maxpoll 5 prefer
You should not prefer a LAN server when you have local PPS.
Oops, missed it. Now removed.

# GPS PPS reference (Only one will be present)
#refclock shm unit 1 refid gPPS minpoll 0 maxpoll 8 prefer
#refclock shm unit 2 refid gPPS minpoll 0 maxpoll 8 prefer
refclock shm unit 1 refid gPPS prefer
refclock shm unit 2 refid gPPS prefer
Don't duplicate the refid.

Once again, you have still not said where SHM(1) and SHM(2) come from.

Well, the only answer I have is that it's from GPSd. I have a single GNSS attached to the Pi. Why SHM(1)? GPSd was started from the command line, not by systemctl. If memory is right, it showed as SHM(1) instead of SHM(2). The fix was too easy to care as to why. I just added the SHM(1) for those times it does. It's disabled now.

Modified:
#refclock shm unit 1 refid gPPS prefer

Right now, GPSd gives me SHM(0) and SHM(2) as visible from ntpshmmon. As it should.

# GPS Serial data reference (NTP0)
#refclock shm unit 0 refid GNSS flag1 0 time1 0.0 minpoll 0 maxpoll 8 
stratum 10 noselect
#refclock shm unit 0 refid GNSS flag1 0 time1 0.025 minpoll 0 maxpoll
8 stratum 10 noselect
# stratum 10
Why is this commented out?  You need SHM(0) to get the right second
for PPS.

I fail to understand how I need SHM(0) if I'm to make it noselect in ntp.conf? It's the serial timestamp, not the PPS from GPSd?

"noselect: Marks the server as unused, except for display purposes. The server is discarded by the selection algorithm." From:https://docs.ntpsec.org/latest/ntp_conf.html

Really confusing.

what is conencted to SHM(2) and SHM(2)?  
Both SHM(1) and SHM(2) are from GPSd.
Obviously, but what is gpsd configured to send as SHM(1) and SHM(2)?
And what happend to SHM(0)?  Very strange configuration.
Depending on how I start GPSd, I get SHM(0) and (SHM(1) or SHM(2), not both). If systemctl starts GPSd, it's gonna be SHM(2). Anyway, I commented out the SHM(1) refclock as it's not normally there.

They are the SHM related to the 
GNSS PPS from the offsets I see. Both are the same PPS from the GNSS 
attached.
You have two PPS sources?  What does that look like on your gpsd command
line?

Only one PPS source (GPIO pin), plus the serial port (no PPS on it).

--/etc/default/gpsd:
# Default settings for the gpsd init script and the hotplug wrapper.

# Start the gpsd daemon automatically at boot time
START_DAEMON="true"

# Use USB hotplugging to add new USB devices automatically to the daemon
USBAUTO="false"

# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
#DEVICES="/dev/ttyAMA0"
DEVICES="/dev/gps0 /dev/pps0"

# Other options you want to pass to gpsd
GPSD_OPTIONS="-n"

GPSD_SOCKET="/var/run/gpsd.sock"
--

--/usr/lib/systemd/system/gpsd.service:
[Unit]
Description=GPS (Global Positioning System) Daemon
Requires=gpsd.socket
# Needed with chrony SOCK refclock
After=chronyd.service
Before=ntpd.service

[Service]
Type=forking
EnvironmentFile=-/etc/default/gpsd
EnvironmentFile=-/etc/sysconfig/gpsd

# Pre-set baud rate of GPS serial port
ExecStartPre=/bin/stty -F /dev/gps0 raw 115200 cs8 clocal -cstopb
ExecStart=/usr/local/sbin/gpsd $GPSD_OPTIONS $OPTIONS $DEVICES

# Give a few seconds for init, that way NTPd will have valid data on start
ExecStart='/bin/sleep 10'

[Install]
WantedBy=multi-user.target
WantedBy=ntpd.service
Also=gpsd.socket
--

Only one shows up, usually SHM(2).
"usually" is not a good thing.  That shows a major problem.  Fix that
before continuing.
It shows only when I start GPSd from the command-line. Haven't seen it for many months because I am using systemctl to stop/start GPSD, and it is SHM(2) now. SHM(1) is a ghost from testing.

I also have SHM(0) from GPSd, and that one jumps ~100ms every 45 
minutes. I assume SHM(0) is from the serial messages. It's disabled.
Don't disable that.  You need that to provide the proper second for the
PPS.  Just "noselect" it.
If I do so, how can NTPsec use it?
"noselect: Marks the server as unused, except for display purposes. The server is discarded by the selection algorithm." From:https://docs.ntpsec.org/latest/ntp_conf.html

Makes me really confused to "need" it, but having it "for display purposes".
I found that
adding NAV-TIMEGPS was fixing the 1 second offset. I've tried it
many times, and disabling NAV-TIMEGPS and stop/start GPSd gets
SHM(2) off by one second. Enabling back the message and stop/start
GPSd and time is good! Odd...  
All you are doing is moving the sentences around.  That can be good
or bad as it affects the parser trying to unroll things.  
Just trying to get it not marked as a falseticker :-/
Uh, completely different levels.  Before you try weird configurations
you need to get the baseline configuration working.  Reset your GPS
to what gpsd expects.

And how did you set that configuration?  With gpsctl, or ubxtool,
defaults, or?  
I configured the u-Blox M8 manually using u-Center on Windows. I 
monitored the output from cgps while doing so to see if the message
was decoded or not and how GPSd reacted to it.
Ugh.  An unmaintainable configuration.  Use gpsctl or ubxtool
to set standard messages.  Better yet, don't touch the defaults.

All right, u-Blox has been reset to defaults with CFG-CFG, Revert to default. I have everything backed up.

sudo systemctl disable gpsd - to prevent interference

sudo ubxtool -e BINARY -f /dev/gps0
sudo ubxtool -d NMEA -f /dev/gps0
sudo ubxtool -s 9600 -S 115200 -f /dev/gps0
sudo ubxtool -s 115200 -f /dev/gps0

sudo systemctl enable gpsd

Now, about sudo ubxtool -d SBAS -f /dev/gps0: it does NOT disable SBAS.

I'm trying to use known tools, but I still have to use u-Center to disable SBAS and set Timing-friendly settings.

Now, I set:
CFG-ANT: Set according the the hardware.
CFG-GNSS: Disable SBAS, Enable Galileo. Sets CFG-SBAS to Disabled.
(Read to the end, GPS/QZSS are the only enabled.)
CFG-ITFM: Set antenna to "active", Enabled.
CFG-NAV5: Dynamic: Stationary, Mode: 2D, set HAE to that of my location.
CFG-NMEA: NMEA version 4.1, Numbering 1-Extended. (Doesn't matter, the messages have been turned off.)
CFG-PMS: Full Power. Sets CFG-RXM Power to 0-Continous.
CFG-PRT: For 1-UART1: Protocol out 0+1 UBX+NMEA. NMEA messages are off anyway.
CFG-TP5: For 0-TIMEPULSE: Set Cable Delay to 15ns, that's for my antenna.
CFG-CFG: Save current configuration.

When GPSd was first installed, it was disabling Galileo and Glonass 
after a while. I now use a jumper to prevent GPSd from reconfiguring
the GNSS.
Uh, that is not gpsd changing your constellations.  To prevent gpsd from
touching your GPS just use the -b command line switch.  But then you got
gpsd all confused.

Once again, gpsd did not do that, but you really do not want to use
Galileo and Glonass when doing timing.  So says the offical u-blox
doc.
Ghost in the machine:
When the jumper is connected, SBAS gets reactivated. I do not see ANY command sent to the GNSS to enable it. In CFG-SBAS, the subsystem becomes enabled, "Allow test mode" enabled (BAD!), as well as "Apply integrity information". That last one will prevent any sat other than GPS from being used because the SBAS satellites visible only carries integrity information for GPS.

I had disabled the ability for GPSd to send to my GNSSr and it fixed the problem, but I now see GPSd is not at fault. Constellations get disabled, although indirectly. It's very odd that only SBAS is affected. could be a u-Blox bug. Dang. I now need to find out why... Possibly some ground loop or RF, my Arduino a few feet away sometimes spontaneously reboots, and it's connected to the same computer.

For now, I'll leave the jumper OFF, as it's already configured. After that ghost, I disabled GPS/QZSS so they are the only ones enabled. SBAS disabled, config checked and saved.

To change the configuration, I connect my serial-USB
adapter and change what I want with u-Center. GPSd can't modify my
settings without me putting the jumper back. I'm just trying to keep
the minimum messages while having Galileo and Glonass active.
Which is wrong on many levels.  Don't fight gpsd doing the right thing.

That is certainly not what gpsd expects, and thus
untested and likely suboptimal.  
OK, then I must ask what does GPSd expect?
I guess you keep missing the part where I say to set your GPS with
gpsctl or ubxtool.

Not every setting I need to set is easily accessible from those tools. Besides, the tool does not matter, as long as the  configuration is good. That is why I described my changes above..

I ran "ubxtool -e BINARY -f /dev/gps0" above. It enabled NAV-POSECEF, NAV-DOP, NAV-VELECEF, NAV-SBAS, plus those I already had, NAV-SOL, NAV-TIMEGPS. It prefers NAV-SVINFO to NAV-SAT, I have no problem with that.

We can't really support configurations that are not well tested
and part of our regressions.  
I don't mind giving full GNSS control back to GPSd, but then, why was
it disabling Galileo and Glonass?
No, it was not.  And anyway that is the right thing to do.
No, GPSd does not send the commands. I even recorded the stream to check. It somehow gets "disabled", but not by GPSd. That is something somewhat solved. :-/

See driver_ubx.c lines 1770+ to see what gpsd does.
For fun, I will likely do ;-)


Too early to look at ntpmon, your pool servers not running yet.  
Well, they where up, and after a while, they where released. NTPd
picks the best and drops the unneeded extras?
No.
When NTPd starts, it does use a associate to a bunch of pool servers. They are later pruned by NTPsec as needed. I just use the pool statement. I don't mess with anything else. If they get pruned, I have no hand in it. That fits what I read there: https://docs.ntpsec.org/latest/discover.html

SHM(1)          .gPPS.           0 l  64    0 0ns      0ns    954ns
Why is SHM(1) broken?

Already answered: It's there only for when GPSd is started from the command-line while debugging. Wierd, but it works, and then it goes back to SHM(2) when systemctl starts it. Disabled now anyway.

After an evening of troubleshooting, time to sleep.

Have a good day tomorrow,
Martin


reply via email to

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