Bosse_B
Posts: 572
Joined: Thu Jan 30, 2014 9:53 am

Cannot get gpsd working on Pi3

Fri Mar 04, 2016 11:06 pm

I posted the thread "USB GPS dongle BU-353 usage on RPi2" on the General discussion sub-forum when I started my quest for GPS on my Pi.
Now when I am having problems I post in Troubleshooting instead.

What has been done:
I switched to a new RPi3 and set it up with Raspbian Jessie (2016-02-26).
Then I tried the suggestions in the first thread to set up gpsd, but it failed in the end.
I have checked these items:
- GPS BU-353 is recognized by Raspbian as a Prolific serial port on ttyUSB0
- I can use stty to open ttyUSB0 and cat the data. NMEA sentences are listed so the GPS works OK.

Code: Select all

stty -F /dev/ttyUSB0 ispeed 4800
cat </dev/ttyUSB0
$GPGGA,205418.306,,,,,0,00,,,M,0.0,M,,0000*59
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,29,53,234,32,17,52,192,,02,44,122,,09,37,050,*71
$GPGSV,3,2,12,26,34,317,28,05,32,160,,31,15,280,,23,14,105,24*7E
...
- Then I installed gpsd and started it:

Code: Select all

sudo apt-get install gpsd gpsd-clients python-gps
sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
According to instructions it should now be possible to see the NMEA data:

Code: Select all

cgps -s
But this shows only a blank panel of placeholders for the data and goes away with a timeout message

Code: Select all

xgps
This brings up a GUI window but it contains no data.
Then I checked if the system was listening to the gpsd TCP port 2947 (which is the default gpsd port):

Code: Select all

pi@rpi3-jessie:~ $ netstat -lnpt
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:2947          0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      650/Xtightvnc
tcp        0      0 0.0.0.0:6001            0.0.0.0:*               LISTEN      650/Xtightvnc
...
So it seems like gpsd is running and listening on the default port.
Still no data shows up.

Is there someone here who can help in debugging the connectivity issue here?
For instance, how does gpsd know the baudrate to use against ttyUSB0? I find no mention of such a setup in any page I have read...

Reference webpages:
http://blog.retep.org/2012/06/18/gettin ... pberry-pi/
http://www.catb.org/gpsd/installation.html
Bo Berglund
Sweden

Bosse_B
Posts: 572
Joined: Thu Jan 30, 2014 9:53 am

Re: Cannot get gpsd working on Pi3

Sat Mar 05, 2016 7:51 am

Further to this I managed to find a list of gpsd commands so I could do this:
- First check that gpsd is not already running
- Then start it with the -N flag to make it display errors

Code: Select all

pi@rpi3-jessie:~ $ ps -e | grep gps
pi@rpi3-jessie:~ $ sudo gpsd /dev/ttyUSB0 -N
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!
Notice that ps does not return any process holding the GPS port 2947 and yet the start command for gpsd (now using the -N debug flag) shows that this port is in fact occupied already!
So I went ahead and checked if there is some process holding that port:

Code: Select all

pi@rpi3-jessie:~ $ netstat -lnpt
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:2947          0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      650/Xtightvnc
tcp        0      0 0.0.0.0:6001            0.0.0.0:*               LISTEN      650/Xtightvnc
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      -
tcp6       0      0 ::1:2947                :::*                    LISTEN      -
tcp6       0      0 :::139                  :::*                    LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 :::445                  :::*                    LISTEN      -
As you can see the port is open on both ipv4 and ipv6 for some strange reason. And to further muddy the waters I do not get a name for the process holding that port either...

I next ried to specifically tell cgps what port to use, but the result was the character screen with no data mentioned before plus now an error message at the bottom:

Code: Select all

cgps localhost:2947:/dev/ttyUSB0
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqklqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x    Time:       n/a                        xxPRN:   Elev:  Azim:  SNR:  Used: x
x    Latitude:   n/a                        xx                                 x
x    Longitude:  n/a                        xx                                 x
x    Altitude:   n/a                        xx                                 x
x    Speed:      n/a                        xx                                 x
x    Heading:    n/a                        xx                                 x
x    Climb:      n/a                        xx                                 x
x    Status:     NO FIX (0 secs)            xx                                 x
x    Longitude Err:   n/a                   xx                                 x
x    Latitude Err:    n/a                   xx                                 x
x    Altitude Err:    n/a                   xx                                 x
x    Course Err:      n/a                   xx                                 x
x    Speed Err:       n/a                   xx                                 x
x    Time offset:     n/a                   xx                                 x
x    Grid Square:     n/a                   xx                                 x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjmqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

r":3,"proto_minor":9}
{"class":"ERROR","message":"No such device as /dev/ttyUSB0"}
Notice the complaint about /dev/ttyUSB0!
This is definitely there, shown inside the /dev dir.
And gpsd is now running too:

Code: Select all

pi@rpi3-jessie:~ $ ps -e | grep gps
18369 ?        00:00:00 gpsd
Even after a reboot netstat shows something holding port 2947 open!
What is going on here, really?
Is it a Raspbian Jessie thing or some kind of firewalling or what?
Bo Berglund
Sweden

Bosse_B
Posts: 572
Joined: Thu Jan 30, 2014 9:53 am

[SOLVED]: Cannot get gpsd working on Pi3

Tue Mar 08, 2016 2:13 pm

I finally got it all working by building from sources.
The apt-get version was really old and therefore not much to spent time on.
I have struggled a bit getting a build to work so I compiled a report available on my site.
Hope it may help someone doing the same as I did.
Bo Berglund
Sweden

Per_L
Posts: 1
Joined: Wed Mar 16, 2016 8:31 am

Re: Cannot get gpsd working on Pi3

Wed Mar 16, 2016 8:48 am

Hi,

Had the same problem.

I think the problem is in how systemd is configured.

Try to change /lib/systemd/system/gpsd.socket
from

ListenStream=127.0.0.1:2947

which listens to localhost only
to

ListenStream=0.0.0.0:2947

which listens to "all" , and restart gpsd (or reboot).

Then netstat -lntp will show

tcp 0 0 0.0.0.0:2947 0.0.0.0:* LISTEN 1/init
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 412/sshd
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 596/0
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 632/1


Regards

Per Linderholm
Sweden

beta-tester
Posts: 993
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Cannot get gpsd working on Pi3

Fri Mar 18, 2016 6:17 am

Per_L wrote:Hi,
...
Try to change /lib/systemd/system/gpsd.socket
from

Code: Select all

ListenStream=127.0.0.1:2947
which listens to localhost only
to

Code: Select all

ListenStream=0.0.0.0:2947
which listens to "all"
...
Regards
Per Linderholm
Sweden
thank you very much... very good hint
that issue caused a lot of headache to me...
now i have access to gps data from everywhere of my network.

do you know the replacement for ipv6?
only to have the same for IPv6 -> tcp6
i tired replacing

Code: Select all

ListenStream=[::1]:2947
with

Code: Select all

ListenStream=[::]:2947
but that will not work
{ I only give negative feedback }
RPi Model B (rev1, 256MB) & B (rev2, 512MB) & B+, RPi2B (1GB), 64GB microSDXC1 class 10, HDMI 1920x1080, keyboard-mouse-combo (wireless), PiCamera, ethernet-cable, 5V/1.2A power supply, Wifi dongle (rt5370)

Bosse_B
Posts: 572
Joined: Thu Jan 30, 2014 9:53 am

Re: Cannot get gpsd working on Pi3

Sat Mar 26, 2016 9:34 am

I have had a difficult time getting gpsd running on boot of my Raspbian Jessie system.
I have finally gotten it to work properly on startup by adding an entry into the bottom of /etc/rc.local:

Code: Select all

#Start the gpsd daemon
/etc/booted/startgpsd.sh
exit 0
And the startgpsd.sh script is here:

Code: Select all

#!/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
and the logfile /startgpsd.txt reads:

Code: Select all

2016-03-26 10:24:20
Starting GPSD
2016-03-26 10:24:22
Now I can connect using the normal gpsd tools like
cgps -s

This was not possible before.

EDIT:
I updated the name of the script to run from rc.local to startgpsd.sh and also changed the logfile name correspondingly.
Bo Berglund
Sweden

beta-tester
Posts: 993
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Cannot get gpsd working on Pi3

Tue Mar 29, 2016 6:02 pm

Bosse_B wrote:I have had a difficult time getting gpsd running on boot of my Raspbian Jessie system...
i got my working automatically on jessie by using the following settings in the /etc/default/gpsd file...

Code: Select all

# /etc/default/gpsd
START_DAEMON="true"
GPSD_OPTIONS="-n"
DEVICES="/dev/ttyAMA0"
USBAUTO="false"
GPSD_SOCKET="/var/run/gpsd.sock"
normally those settings should be configured by using dpkg-reconfigure gpsd...
but for unknown reason that command wasn't doing anything on my RPi. do i had to do the configuration by hand on the /etc/default/gpsd file.

i had an other issue, that the gpsd data wasn't recognized automatically by ntpd but that is a complete other story.
{ I only give negative feedback }
RPi Model B (rev1, 256MB) & B (rev2, 512MB) & B+, RPi2B (1GB), 64GB microSDXC1 class 10, HDMI 1920x1080, keyboard-mouse-combo (wireless), PiCamera, ethernet-cable, 5V/1.2A power supply, Wifi dongle (rt5370)

drclong
Posts: 1
Joined: Wed Jun 08, 2016 12:30 am

Re: Cannot get gpsd working on Pi3

Wed Jun 08, 2016 12:34 am

by Bosse_B » Tue Mar 08, 2016 2:13 pm
I finally got it all working by building from sources.
The apt-get version was really old and therefore not much to spent time on.
I have struggled a bit getting a build to work so I compiled a report available on my site.
Hope it may help someone doing the same as I did.
Bo Berglund
Sweden
Thank you for the help but I have run into a problem on your report where I can not install libxlt1-dev. Package is not available. Have tried updating and upgrading but no solution so far.

Any ideas?

Bosse_B
Posts: 572
Joined: Thu Jan 30, 2014 9:53 am

Re: Cannot get gpsd working on Pi3

Fri Jun 10, 2016 9:30 pm

I don't know...
When I had the problem with libxslt back in March I asked in this forum thread and was directed towards the use of libxlt1-dev instead.
Then it worked and I have not looked at this since...
Bo Berglund
Sweden

beijota2
Posts: 2
Joined: Wed Aug 24, 2016 5:07 pm

Re: Cannot get gpsd working on Pi3

Wed Aug 24, 2016 10:57 pm

drclong wrote:
Thank you for the help but I have run into a problem on your report where I can not install libxlt1-dev. Package is not available. Have tried updating and upgrading but no solution so far.

Any ideas?
I did a search for libxlt1-devcouple of searches and found a libxslt1-dev instead. I ran thru Bo's process and It worked for a while, but now i'm back to the same error message

Code: Select all

root@BBG1:~# gpsd -N -D3 -F /var/run/gpsd.sock
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
Working my way thru the steps again to see if I can find the 'Magic' tweak.

Bosse_B
Posts: 572
Joined: Thu Jan 30, 2014 9:53 am

Re: Cannot get gpsd working on Pi3

Thu Aug 25, 2016 6:48 am

As indicated in the error message there may be another instance of gpsd running already.
You may want to check if there are other gpsd processes running and delete them if so.
If there is no other gpsd running then you should not have this problem.
This will show the running instances of gpsd:

Code: Select all

ps aux | grep gpsd
nobody    1225  1.0  0.2  11748  2160 ?        S<sl 08:51   0:02 /usr/local/sbin/gpsd /dev/ttyUSB0 -G -n -F /var/run/gpsd.sock
Bo Berglund
Sweden

delorian1986
Posts: 4
Joined: Mon Jul 20, 2015 12:02 pm

Re: Cannot get gpsd working on Pi3

Thu Aug 25, 2016 8:58 pm

Hi there.
I am still using raspberry 2 but i just installed gpsd with the usual

Code: Select all

sudo apt-get install
and got the gps running by turning off the gpsd.socket using

Code: Select all

sudo systemctl stop gpsd.socket
and then

Code: Select all

 sudo systemctl disable gpsd.socket
.
I found this on adafruits homepage https://learn.adafruit.com/adafruit-ult ... i/use-gpsd over their own gps module and it worked for my USB dongle :D.
Hope this helps! :)
Best regards

scorpion001
Posts: 1
Joined: Wed Nov 09, 2016 2:23 pm

Re: Cannot get gpsd working on Pi3

Wed Nov 09, 2016 2:57 pm

There is a mistake in the blog your provided.
sudo apt-get install libxlt1-dev docbook-xsl xmlto asciidoc
libxlt1-dev should change to libxslt1-dev

nullacht15
Posts: 7
Joined: Wed Nov 23, 2016 8:14 am

Re: Cannot get gpsd working on Pi3

Wed Nov 23, 2016 8:42 am

beta-tester wrote:
Bosse_B wrote: i had an other issue, that the gpsd data wasn't recognized automatically by ntpd but that is a complete other story.
How did you solve this issue regarding ntpd?
my gpsd is running and cgps -s is giving me the right results but ntp is not working :(

/etc/default/gpsd

Code: Select all

START_DAEMON="true"
USBAUTO="true"
DEVICES="/dev/ttyUSB0"
GPSD_OPTIONS="-n"
GPSD_SOCKET="/var/run/gpsd.sock"
/etc/ntp.conf

Code: Select all

server 127.127.28.0
fudge 127.127.28.0 time1 +0.175 refid GPS stratum 3
ntpq -p:

Code: Select all

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 SHM(0)          .GPS.            3 l    -   64    0    0.000    0.000   0.000
Any ideas?

beta-tester
Posts: 993
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Cannot get gpsd working on Pi3

Wed Nov 23, 2016 1:15 pm

nullacht15 wrote:
beta-tester wrote:
Bosse_B wrote: i had an other issue, that the gpsd data wasn't recognized automatically by ntpd but that is a complete other story.
How did you solve this issue regarding ntpd?
my gpsd is running and cgps -s is giving me the right results but ntp is not working :(

/etc/default/gpsd

Code: Select all

START_DAEMON="true"
USBAUTO="true"
DEVICES="/dev/ttyUSB0"
GPSD_OPTIONS="-n"
GPSD_SOCKET="/var/run/gpsd.sock"
/etc/ntp.conf

Code: Select all

server 127.127.28.0
fudge 127.127.28.0 time1 +0.175 refid GPS stratum 3
ntpq -p:

Code: Select all

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 SHM(0)          .GPS.            3 l    -   64    0    0.000    0.000   0.000
Any ideas?
i solved it by using the GPS NMEA data as the first ntp time source to get the date and time.
and used the GPS PPS signal for precise sync trigger ntp as second time source.
and force ntp to use the NMEA as preferred time source, otherwise ntp will not take that source in account, because it is relative inaccurate.

Code: Select all

# gpsd: GPS NMEA serial data reference
server 127.127.28.0  minpoll 4  maxpoll 4 prefer
fudge 127.127.28.0  refid NMEA  stratum 3  time1 0.510
and test, if ntp takes the GPS NMEA data into account, just after you did cgps -s once, then you have to "trigger" the gpsd at every start cycle like me.
see this thread: [FIXED]: RPi as high precise NTP Server with GPS/PPS dev
{ I only give negative feedback }
RPi Model B (rev1, 256MB) & B (rev2, 512MB) & B+, RPi2B (1GB), 64GB microSDXC1 class 10, HDMI 1920x1080, keyboard-mouse-combo (wireless), PiCamera, ethernet-cable, 5V/1.2A power supply, Wifi dongle (rt5370)

nullacht15
Posts: 7
Joined: Wed Nov 23, 2016 8:14 am

Re: Cannot get gpsd working on Pi3

Wed Nov 23, 2016 4:42 pm

thank you, seems to work now :)

Return to “Troubleshooting”

Who is online

Users browsing this forum: No registered users and 54 guests