Synchronizing clock with GPS using NMEA messages (TCP source) + PPS signal

I’m currently working on a Nvidia Jetson TX2 with Ubuntu 18, using an Emlid Reach GPS Module which is capable of provide NMEA messages through a TCP connection and a 1-PPS signal through a UART pin.

I’m not being able to correctly sync the system clock with the GPS clock.

I was able to compile the linux kernel with the required PPS flags:

CONFIG_PPS=y
CONFIG_PPS_DEBUG=y
CONFIG_PPS_CLIENT_KTIMER=y
CONFIG_PPS_CLIENT_LDISC=y
CONFIG_PPS_CLIENT_GPIO=y

And I managed to correctly expose a GPIO pin (modifying the kernel dts), obtaining two devices: /dev/pps0 and /dev/pps1. pps0 corresponds to the kernel PPS and pps1 is a PPS related to a GPIO pin in the board.

The GPS module is connected with a USB cable but provides data by creating a USB-To-Ethernet interface and responding on IP 192.168.2.15, TCP port for data acquisition is configurable and set at port 9001. The PPS signal is connected to a pin in the jetson.

My issue is that some gps/pps tools give me satisfactory results while others fail horribly.

Testing both pps signals:

 sudo ppstest /dev/pps0
 sudo ppstest /dev/pps1

Gives satisfactory results:

trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1657740302.347287559, sequence: 6590 - clear  0.000000000, sequence: 0
...

But the ppscheck tool doesn’t and fails with:

$ sudo ppscheck /dev/pps0
# Seconds  nanoSecs   Signals
PPS ioctl(TIOCMIWAIT) failed: 25 Inappropriate ioctl for device

gpsmon is able to get the NMEA data from the TCP connection but not the PPS, the PPS line remains blank with:

sudo gpsmon -D 5 192.168.2.15:9001:/dev/pps0

On the other hand trying to configure gpsd fails, using:

sudo gpsd -D 5 -N -n tcp://192.168.2.15:9001
gpsd:INFO: launching (Version 3.17)
gpsd:IO: opening IPv4 socket
gpsd:ERROR: can't bind to IPv4 port gpsd, Address already in use
gpsd:ERROR: maybe gpsd is already running!

Trying with the GPS PPS, /dev/pps1 gives me same results.

Which would be the proper way to configure gpsd to take NMEA data from a TCP connection + a device PPS signal?
Does anyone has some information on that PPS “Inappropriate ioctl for device” error?

Thankss

please see-also Topic 107409 to use GPIO as PPS interface.

I actually found this post most useful:

I already managed to expose the pin in the device tree and compile the kernel with the PPS features.

The PPS signal seems to be there and working for both the kernel pps (/dev/pps0) and the device pps through the pin (/dev/pps1).

The PPS output signal (from the gps) seems correct when inspected with an osciloscope.
And,

sudo ppstest /dev/pps1

shows me a steady signal with timestamps without drift.

My problem is with what comes next, configuring the daemon GPSD and feed the system clock with the NMEA messages + PPS signal.