I have several Raspberry Pi around my apartment in various states of development projects running different versions of Raspian. I’ve been playing with GPSD recently and want the services to be transparently available on each Pi without having to connect directly via a USB port. It turns out that making it work is easy, but obscure.
On my machine that has the GPS plugged into the USB port I need to change the
/lib/systemd/system/gpsd.socket file to allow the socket to be visible on the network. On my Raspian Buster machine, it originally looked like this
[Unit] Description=GPS (Global Positioning System) Daemon Sockets [Socket] ListenStream=/var/run/gpsd.sock ListenStream=[::1]:2947 ListenStream=127.0.0.1:2947 SocketMode=0600 [Install] WantedBy=sockets.target
I changed it to look like this
[Unit] Description=GPS (Global Positioning System) Daemon Sockets [Socket] ListenStream=/var/run/gpsd.sock ListenStream=[::]:2947 ListenStream=0.0.0.0:2947 SocketMode=0600 [Install] WantedBy=sockets.target
I was able to test that it was working properly by running the command
gpsmon WimPi4:2497 on the remote host. WimPi4 is the hostname of my machine with the GPS installed.
On the machines I wanted access to the GPS, I modified the file
/etc/default/gpsd by adding an entry in the DEVICES section to make the file below.
# Devices gpsd should collect to at boot time. # They need to be read/writeable, either by user gpsd or the group dialout. DEVICES="gpsd://WimPi4" # Other options you want to pass to gpsd GPSD_OPTIONS="" # Automatically hot add/remove USB GPS devices via gpsdctl USBAUTO="true"
With the changes to the gpsd configuration I was able to run cgps or gpsmon on the client machines without requiring an argument. The client programs are connecting the local daemon, which is then connecting to the machine with the gps receiver running gpsd.