1

After reinstalling Raspbian Buster I'm always running into an issue with my gpsd 3.17: Despite the fact that I start it with the corresponding device file /dev/ttyS0 as a parameter (because the GPS receiver hangs on it), it seems to access other serial devices as well, including /dev/ttyUSB0, which stands for a GNS FM9 TMC receiver without any GPS functionality, thereby causing a deadlock in my app. Here is the status of the gpsd I get from systemctl:

pi@autoradio:/import/valen/autoradio $ sudo systemctl status gpsd
● gpsd.service - GPS (Global Positioning System) Daemon
   Loaded: loaded (/lib/systemd/system/gpsd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2021-09-16 23:14:08 CEST; 24h ago
  Process: 412 ExecStart=/usr/sbin/gpsd $GPSD_OPTIONS $DEVICES (code=exited, status=0/SUCCESS)
 Main PID: 463 (gpsd)
    Tasks: 1 (limit: 2059)
   CGroup: /system.slice/gpsd.service
           └─463 /usr/sbin/gpsd /dev/ttyS0

Sep 16 23:14:08 autoradio systemd[1]: Starting GPS (Global Positioning System) Daemon...
Sep 16 23:14:08 autoradio systemd[1]: Started GPS (Global Positioning System) Daemon.

So it should be restricted to the Pi's on-board UART named /dev/ttyS0. Before being accessed for the first time, gpsd seems not to open any of the serial devices:

pi@autoradio:/import/valen/autoradio $ sudo lsof /dev/ttyUSB0

pi@autoradio:/import/valen/autoradio $ sudo lsof /dev/ttyS0

pi@autoradio:/import/valen/autoradio $

But: Once I start my app (named autoradio), the daemon suddenly opens both serial devices:

pi@autoradio:/import/valen/autoradio $ sudo lsof /dev/ttyS0
COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
gpsd    463 gpsd    8u   CHR   4,64      0t0  133 /dev/ttyS0

pi@autoradio:/import/valen/autoradio $ sudo lsof /dev/ttyUSB0
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
gpsd      463 gpsd    9u   CHR  188,0      0t0  433 /dev/ttyUSB0
autoradio 937   pi    7u   CHR  188,0      0t0  433 /dev/ttyUSB0

And this is what I do not want, as I'm accessing /dev/ttyUSB0 directly from my app. The code connecting to gpsd looks very simple (irrelevant parts omitted):

tmc::tmc ()
: gps_handler ("localhost", DEFAULT_GPSD_PORT)
{
}

void tmc::Initialize ()
{
gps_data_t* response;

response = this -> gps_handler.stream (WATCH_ENABLE | WATCH_JSON);
}

So: How do I prevent gpsd from accessing any device other than /dev/ttyUSB0, preferably already when starting it up? What's really strange: Why does this issue arise after reinstalling Raspbian? Thank you.

UPDATE: I've looked into my /etc/default/gpsd config file to find this (comments removed):

START_DAEMON="true"
USBAUTO="true"
DEVICES="/dev/ttyS0"
GPSD_OPTIONS=""

Setting the -n option did not work BTW.

2
  • Edit /etc/defaults/gpsd change the DEVICES="" line to define the /dev/ttyXXX device you want it to use.
    – Dougie
    Sep 18, 2021 at 11:44
  • 1
    Already done that, but no use.
    – Neppomuk
    Sep 18, 2021 at 22:32

1 Answer 1

0

OK, I've already had a slight suspicion that the following line in the config file was the culprit, and now I've found out that this was really the case:

USBAUTO="true"

Set this to false to prevent the daemon to look for GPS receivers hanging on USB ports, and the problem is solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.