Linux – Access NMEA reference clock and GPS position simultaneously

devicesgpslinuxntpd

I noticed two approaches to get an accurate time from GPS (with PPS). Using ntpd either with

My problem:
I want to have a very accurate time and access to GPS position data.
Therefore using Shared Memory via gpsd is possibly to slow.

In my ntp configuration I currently use a NMEA reference clock.
The GPS reciever (with PPS) is connected to /dev/ttyS0 and /dev/gps0 respectively.

I cannot use both, ntpd with NMEA and gpsd to get position data, in parallel.
If ntpd is running gpsd will get no data and exits after timeout.
But if ntpd is running cat /dev/ttyS0 print NMEA data on the console. So I can read from the serial line.
So why gpsd cannot access the serial data if ntpd is running? The debug messages of gpsd I pasted here. I start gpsd and then try to connect with cgps.

I know thats maybe a question of opening devices in parallel in general…

EDIT

Right now I use

server 127.127.20.0 mode 18 minpoll 4 maxpoll 4 iburst prefer true
fudge 127.127.20.0 flag1 1 flag2 0 flag3 1 flag4 0 time2 0.475

Retrieve the position data from the clockstats file will work.
May there is a better solution for that than parsing this file?

Best Answer

Why use gpsd? Just use the NMEA driver and enable PPS with flag1:

server 127.127.20.0 minpoll 4  mode 18 prefer   # NMEA serial port, 16 = 9600 baud, 2 = $GPGGA
fudge 127.127.20.0  time2 0.435 flag1 1 flag3 0

You should change your fudge time to whatever is appropriate.

You can get the position data from the clockstats file.