This document is a loose collection of application- and device notes.
Sharing a GPS device between trx-control and other applications
By Christian Häusler HB9HOX
This application note explains how to configure trx-control to get GPS information from gpsd instead directly from a GPS device. |
Context
Usually, GPS devices present themselves as a serial device to the computer. One characteristic properties of serial devices are that they can only be access by one application at a time. This becomes an issue for devices like a GPS. Usually we want to make the position available to multiple applications at the same time (for example chronyd to update our system time, a map for navigation, our logging software to have the correct grid square in for our QSOs).
To solve this dilemma, the software gpsd has been created. As of October 2024, trx-control can not use gpsd as position source. With a bit of clever Linux configurations, we can work around this. As a bonus, we also get hot plug support.
Idea
-
gpsd connects to the GPS device as it is intended to do
-
a virtual serial device is created
-
the NMEA data get streamed from gpsd into that virtual serial device
-
trx-control is configured to read NMEA data from that virtual serial device
Solution
-
gpspipe
allows streaming the NMEA data from gpsd -
socat
is a powerful tool to transfer data between a plethora of sources and targets. -
a Systemd unit ensures the virtual serial device is present before trxd starts
[Unit] Description=Virtual nmea serial device for trx-control
Requires=gpsd.service
After=gpsd.service
Before=trxd.service
[Service]
ExecStart=/bin/sh -c 'gpspipe --nmea | socat stdin pty,link=/dev/trxd-nmea,mode=666'
[Install]
RequiredBy=trxd.service
Instructions
-
Place the above Systemd unit at
/etc/systemd/system/trxd-nmea
-
Reload Systemd:
sudo systemctl daemon-reload
-
Enable the Systemd unit:
sudo systemctl enable trxd-nmea
-
Configure
/dev/trxd-nmea
as NMEA device in thenmea:
section of your trxd configuration file -
Restart trxd:
sudo systemctl restart trxd
Explanation
-
gpspipe --nmea
reads position data from pgsd and writes NMEA sentences to standard out. -
socat stdin pty
creates a PTY device and writes anything from STDIN to that PTY. This creates a device named/dev/pts/<N>
where<N>
is a random number. -
To prevent us from changing the configuration of trxd every time,
link=/dev/trxd-nmea
creates a stable link to that device. -
mode=666
makes the device readable by all users. -
Requires=gpsd.service
andAfter=gpsd.service
ensures gpsd gets started and is up and running before this unit can start. -
RequiredBy=trxd.service
andBefore=trxd.service
ensures this unit gets started before and is running before trxd gets started.
Contribute to the Application Notes
Required Format
If you want to contribute an application or device note, please send it in the following format for inclusion:
-
Use AsciiDoctor (.adoc) format
-
Wrap lines at 72 characters