2

I'm a complete newbie with GPS devices on Linux.

I have a GlobalSat G-STAR IV USB device and I would just like to get the GPS location (lat, long) printed to stdout. How can I achieve that? I'm reading about gpsd, but not sure how to get the actual location. The documentation seems old.

Any common tools etc for this?

It seems that with

$ sudo stty -F /dev/ttyUSB0 4800
$ sudo cat /dev/ttyUSB0

I can read some NMEA(?) data from the device:

$GPGGA,113935.199,,,,,0,00,,,M,0.0,M,,0000*5B

$GPGSA,A,1,,,,,,,,,,,,,,,*1E

$GPRMC,113935.199,V,,,,,,,100918,,,N*41

$GPGGA,113936.186,,,,,0,00,,,M,0.0,M,,0000*56

$GPGSA,A,1,,,,,,,,,,,,,,,*1E

$GPRMC,113936.186,V,,,,,,,100918,,,N*4C

$GPGGA,113937.185,,,,,0,00,,,M,0.0,M,,0000*54

$GPGSA,A,1,,,,,,,,,,,,,,,*1E

$GPRMC,113937.185,V,,,,,,,100918,,,N*4E

$GPGGA,113938.200,,,,,0,00,,,M,0.0,M,,0000*55

$GPGSA,A,1,,,,,,,,,,,,,,,*1E

I still don't see $GPGLL that should contain the location..?

Edit: I also get this:

$ 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!

I have killed all gpsd instances and deleted the socket, but still getting that..

juzzlin
  • 45,029
  • 5
  • 38
  • 50

2 Answers2

5

The output you posted from sudo cat /dev/ttyUSB0 is what you would expect for a GPS module, which does not (yet) have a fix, i.e. it does not have enough information to calculate its current position (+other information).

The only information provided by the messages is the current time of day, 11h39m35s, etc. Out of the messages you receive from your GPS module, not only the $GPGLL message can tell you about your location, but also the $GPGGA and $GPRMC messages that you do receive. If your module had a fix, you would not see several commas in a row but actual values in between.
More details about the format of the different messages can be found in this overview.

What is the likely root cause for the missing GPS fix (assuming your hardware + antenna are fine)?

  • You have just started using this module fresh from the factory and it needs some time to get ahold of its coordinates. The time to first fix for such a brand new device can be up to 15 minutes.
  • The GPS signal strength is not strong enough at the location of your module.

Therefore my advice:

  • Make sure that at your location, the GPS signal from the satellites is strong enough. Ideally by moving outdoors.
  • When your module has never had a fix before, give your module some time. Wait for up to 20 minutes.

GPSD:

GPSD, if installed, is normally started automatically, when you plug in a GPS module. You can check the current status with

systemctl status gpsd.service
systemctl status gpsd.socket

If active, the gpsd deamon reads out the GPS-data coming via the serial interface and provides it to other applications via a socket on a specific port (default: port 2947). In that case the serial port is not accessible anymore by serial monitors.

oh.dae.su
  • 607
  • 6
  • 12
3

Steps to make this device work were:

# Switch the device to NMEA mode
sudo gpsctl -f -n /dev/ttyUSB0

# Set baudrate to 4800
sudo stty -F /dev/ttyUSB0 4800

# Start gpsd 
gpsd -S 4000 /dev/ttyUSB0

Now create a TCP/IP socket connection to localhost:4000 and say ?WATCH={"enable":true,"json":true}; or use libgps etc:

http://www.catb.org/gpsd/client-howto.html

juzzlin
  • 45,029
  • 5
  • 38
  • 50
  • `joaquin@hamradio:~$ sudo gpsctl -f -n /dev/ttyUSB0` `gpsctl:ERROR: SER: /dev/ttyUSB0 already opened by another process` `gpsctl:ERROR: initial GPS device /dev/ttyUSB0 open failed` – joaquin Sep 10 '20 at 10:41
  • sorry for the fragmented comment. Just to clarify : Same GPS, got data with `sudo stty -F /dev/ttyUSB0 4800`, but `sudo gpsctl...` fails as shown above – joaquin Sep 10 '20 at 10:50
  • Check if you have `gpsd` already running on that device..? – juzzlin Sep 10 '20 at 10:53
  • It was stopped. I ran `sudo killall gpsd`. BTW, This is Ubuntu 20.04 – joaquin Sep 10 '20 at 11:13
  • 1
    Made if run after two days fighting. Thanks for help. Just a) start Ubuntu b) connect gps c) run indicated steps in the answer. – joaquin Sep 10 '20 at 11:44
  • Yeah, it was horror to figure out. The good thing is that the setup works very reliably once you have managed to get it running in the first place. – juzzlin Sep 10 '20 at 11:49