I'm having a problem starting GPSD on a Beaglebone Green. I get a socket bind error:
root@BBG1:/etc/init# gpsd -D3 -n -N /dev/ttyUSB0 gpsd:INFO: launching (Version 3.16) gpsd:ERROR: can't bind to IPv4 port gpsd, Address already in use gpsd:ERROR: maybe gpsd is already running! gpsd:ERROR: can't bind to IPv6 port gpsd, Address already in use gpsd:ERROR: maybe gpsd is already running! gpsd:INFO: command sockets creation failed, netlib errors -1, -1
It appears the issue is common on these mini dev boards (Raspberry Pi included) but what seems to fix the problem for most people hasn't worked for me. Near as I can tell, it's because
systemd/init are beating gspd to it.
root@BBG1:/etc/init# netstat -lnpt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:2947 0.0.0.0:* LISTEN 1/init tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 375/connmand tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 493/sshd tcp6 0 0 ::1:2947 :::* LISTEN 1/init tcp6 0 0 :::8080 :::* LISTEN 631/apache2 tcp6 0 0 :::80 :::* LISTEN 1/init tcp6 0 0 ::1:53 :::* LISTEN 375/connmand tcp6 0 0 :::22 :::* LISTEN 493/sshd tcp6 0 0 :::1880 :::* LISTEN 1/init tcp6 0 0 :::3000 :::* LISTEN 1/init
0.0.0.0:2947but when I reboot,
initbinds to that instead (as seen in code block above).
sudo killall gspdand then restarting again, but that doesn't seem to help.
/etc/default/gpsdto the following:
START_DAEMON="true" GPSD_OPTIONS="" DEVICES="/dev/ttyUSB0" USBAUTO="false" GPSD_SOCKET="/var/run/gpsd.sock"
a custom boot script in
/etc/rc.local(supposed to delay the startup of gpsd, but it doesn't seem to be running because the startgpsd.txt file never updates)
#Start the gpsd daemon /etc/booted/startgpsd.sh exit 0
which points to startgpsd.sh
#!/bin/sh -e #Need to wait past boot so everything is done date "+%Y-%m-%d %H:%M:%S" > /startgpsd.txt sleep 2 echo "Starting GPSD" >> /startgpsd.txt /usr/local/sbin/gpsd /dev/ttyUSB0 -G -n -F /var/run/gpsd.sock date "+%Y-%m-%d %H:%M:%S" >> /startgpsd.txt exit 0 p
At one point when I upgraded GSPD from v 3.11 (downloaded with
apt-get) to v 3.16 (downloaded the binary and a gig+ of other crap so I could build it) it started working, but as soon as I rebooted I was back to the same problem.
Is there a way to stop systemd from binding to the port so gpsd can instead (or is that even my problem)? Killing PID 1 doesn't seem like a smart thing to do, so I haven't tried that yet. I'm almost to the point of wiping everything and starting all over, but I thought I would try to harness the 'collective power of genius' here first (given that I've already found several answers to other problems here in the past).
Edit: Adding the contents of
[Unit] Description=GPS (Global Positioning System) Daemon Sockets [Socket] ListenStream=/var/run/gpsd.sock ListenStream=[::1]:2947 ListenStream=0.0.0.0:2947 SocketMode=0600 [Install] WantedBy=sockets.target