0x0000
Posts: 137
Joined: Tue Aug 27, 2013 8:59 pm

reading GPS co-ordinates using Python in Raspberry Pi

Wed Dec 25, 2013 4:46 pm

I am trying to run my USB based GPS in Linux but couldn't be able to run it, What I want to do is to convert the Output into NMEA mode before reading it,

So What I did is,

Code: Select all

gpsctl -f -n /dev/ttyUSB0
I have read about it from, http://www.catb.org/gpsd/gpsctl.html

here,

Code: Select all

-f :Force low-level access (not through the daemon).

-n:Put GPS into NMEA mode.
But consistently getting this error,

Code: Select all

gpsctl:SHOUT: vendor/product match with 091e:0003 not found 
gpsctl:ERROR: packet recognition timed out.
I have also tried,

Code: Select all

gpsctl -n /dev/ttyUSB0
But consistently getting this error,

Code: Select all

gpsctl:ERROR: timed out after 8 seconds
gpsctl:ERROR: no DEVICES response received.
I have also tried this with gpsd running but still no luck

The issue is, Sometime, out of no where it successfully convert into NMEA mode when running the same commands, while most of the time it gives the above error.

What I really wanted to do is to read just the Longitude, Latitude and Altitude from the GPS readings, and it requires me to convert the output into NMEA mode. which I couldn't be able to done.

What is the issue here and What am I doing wrong ?

Is there any other way to read the Lat, Long, and Altitude from the USB based GPS under linux using Python or even Command line ?

paulie
Posts: 275
Joined: Thu Jan 19, 2012 6:51 pm

Re: reading GPS co-ordinates using Python in Raspberry Pi

Wed Dec 25, 2013 5:27 pm

As far as I am aware, most GPS devices output NMEA strings as default.
They sometimes have a proprietary 'data' mode, but this is not as easy to use, or read by eye.
If you can get valid NMEA data, you can parse it to get the fields you may need.
It has been my custom to use Xeyes

tvoverbeek
Posts: 101
Joined: Mon Feb 04, 2013 9:50 am
Location: Fieberbrunn, Austria

Re: reading GPS co-ordinates using Python in Raspberry Pi

Wed Dec 25, 2013 6:47 pm

Here is your problem:

Code: Select all

gpsctl:SHOUT: vendor/product match with 091e:0003 not found 
gpsctl:ERROR: packet recognition timed out.
The usb vendor/product id 091e:0003 is for a Garmin GPS unit.
Garmin units need the following kernel module loaded: garmin_gps.
You can check if it is loaded using the command

Code: Select all

lsmod
in a terminal window.

If not loaded you can force to load it using the command

Code: Select all

sudo modprobe garmin_gps
With the module loaded gpsd should recognize your GPS.
Hope this helps.

0x0000
Posts: 137
Joined: Tue Aug 27, 2013 8:59 pm

Re: reading GPS co-ordinates using Python in Raspberry Pi

Thu Dec 26, 2013 10:01 am

tvoverbeek wrote:Here is your problem:

Code: Select all

gpsctl:SHOUT: vendor/product match with 091e:0003 not found 
gpsctl:ERROR: packet recognition timed out.
The usb vendor/product id 091e:0003 is for a Garmin GPS unit.
Garmin units need the following kernel module loaded: garmin_gps.
You can check if it is loaded using the command

Code: Select all

lsmod
in a terminal window.

If not loaded you can force to load it using the command

Code: Select all

sudo modprobe garmin_gps
With the module loaded gpsd should recognize your GPS.
Hope this helps.
Your solution didn't work, this guy -> http://astrobeano.blogspot.com/2012/10/ ... ry-pi.html
had the same issue but he managed to fix it.

Also, How could I check what type of GPS I have, I am currently using BU-353 S4 USB GPS by GlobalSat but you've said its Garmin.

How did you check it is garmin ?

also, is there any possibility that the issue is causing due to no aerial view ?
Because I am operating GPS from indoor.

Also, is there any way to read GPS output using Python beside the use of GPSD or GPSCTL

0x0000
Posts: 137
Joined: Tue Aug 27, 2013 8:59 pm

Re: reading GPS co-ordinates using Python in Raspberry Pi

Thu Dec 26, 2013 1:27 pm

Update:

I manage to sort out the issue but yet I couldn't be able to fix it,

Here is what actually happens when I run the above commands,
gpsctl:INFO: startup at 2013-12-26T13:16:50.000Z (1388063810)
gpsctl:PROG: initialization passed.
gpsctl:PROG: no etc/gpsd/device-hook present, skipped running ACTIVATE hook
gpsctl:INFO: opening GPS data source type 3 at '/dev/ttyUSB0'
gpsctl:INFO: speed 9600, 8N1
gpsctl:PROG: Probing "Garmin USB binary" driver...
gpsctl:INFO: attempting USB device enumeration.
gpsctl:INFO: 0424:9512 (bus 1, device 2)
gpsctl:INFO: 1d6b:0002 (bus 1, device 1)
gpsctl:INFO: 0424:ec00 (bus 1, device 3)
gpsctl:INFO: 0cf3:9271 (bus 1, device 4)
gpsctl:INFO: 067b:2303 (bus 1, device 5)
gpsctl:SHOUT: vendor/product match with 091e:0003 not found
gpsctl:PROG: Probe not found "Garmin USB binary" driver...
gpsctl:PROG: Probing "GeoStar binary" driver...
gpsctl:PROG: Probe not found "GeoStar binary" driver...
gpsctl:PROG: Probing "Trimble TSIP" driver...
gpsctl:INFO: speed 9600, 8O1
gpsctl:INFO: speed 9600, 8N1
gpsctl:PROG: Probe not found "Trimble TSIP" driver...
gpsctl:PROG: no probe matched...
gpsctl:INFO: gpsd_activate(): activated GPS (fd 3)
gpsctl:DATA: packet mask = {}
gpsctl:DATA: packet mask = {}
gpsctl:DATA: packet mask = {}
gpsctl:ERROR: packet recognition timed out.
The gpsctl tries to recognize the type of GPs that I have connected, but it couldn't be able to find it out. But Sometimes it does manage to find out the type (which is "SiRF binary") and at that time it successfully converts into NMEA mode.

Also, the gpsctl command is trying to set the baud rate to 9600, but the correct baud rate is 4800.

I don't know why it is not able to recognize the type of device and the baud rate.

from this page, http://www.catb.org/gpsd/gpsctl.html I have found out that i can force the device type using -t So I tried this,
gpsctl -n -f -t "SirF binary" -D 4 /dev/ttyUSB0
but still getting the same response with one extra line in the output,
gpsctl:ERROR: no driver type name matches 'SirF binary'.
as i mentioned above that sometimes it successfuly recognizes the device type (which is SiRF binary) and baud rate (which is 4800), in such cases of success it converts the mode to NMEA


I have also tried forcing the baud rate to 4800 but it didn't work either.

Is there any way to set the driver to SirF binary and baud rate to 4800 by default by modifying some sort of files in the Linux ?

RH314
Posts: 8
Joined: Thu Jan 30, 2014 3:23 pm

Re: reading GPS co-ordinates using Python in Raspberry Pi

Thu Jan 30, 2014 10:42 pm

GPS modules typically have NMEA output mode and binary output mode. If shipped GPS module somehow inadvertently set into binary mode during production testing, it might result in the problem described. One way to sort it out is to connect the GPS module to a PC, use the GPS module evaluation program from the GPS module vendor to connect to it and you should be able to easily set it into NMEA mode from button on the GUI or some pull-down binary command menu. If it’s 3.3V UART output GPS module used, you likely need a UART-to-USB break board (SparkFun...) to connect to PC. If you don’t have the GPS evaluation software, Google for the GPS receiver model, find the manufacturer and ask for it from their website contact.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: reading GPS co-ordinates using Python in Raspberry Pi

Fri Jan 31, 2014 2:22 am

Actually, gpsd will switch the GPS module to binary mode if it's supported.

You need to choose whether you want to interact with the GPS yourself, in which case you get rid of gpsd and just open the serial port that the GPS is attached to (which may be a USB virtual serial port). Or, let gpsd control the GPS and your program interacts with gpsd.

Since you said you don't want gpsd and gpsctl then you need to get rid of them. But first you need to switch the GPS back to NMEA mode.

This won't work: gpsctl -n -f -t "SirF binary" -D 4 /dev/ttyUSB0

You are telling the GPS to switch to NMEA mode (-n) and then force the device to SirfStar binary mode, which are mutually exclusive.

Instead, try just using -n, i.e. gpsctl -n -D 4 /dev/ttyUSB0

Then use a terminal program such as minicom, or just dump from the serial port to the screen with cat or tail.

e.g. tail -f /dev/ttyUSB0

You should see lots of single-line strings beginning with $GP, and the most interesting one is $GPRMC.

In Python, open the serial port for reading, get some data, look for $GPRMC and pick apart the following data to get lat/lon etc.

But really, gpsd does all that for you if you're willing to let it take over.

CarlD
Posts: 1
Joined: Mon Jun 02, 2014 11:23 am

Re: reading GPS co-ordinates using Python in Raspberry Pi

Mon Jun 02, 2014 11:24 am

Hi,

Were you ever able to resolve this? I have become very frustrated with this having the same issues you are describing.

Thanks

paulie
Posts: 275
Joined: Thu Jan 19, 2012 6:51 pm

Re: reading GPS co-ordinates using Python in Raspberry Pi

Mon Jun 02, 2014 6:16 pm

0x0000 wrote:Update:

gpsctl -n -f -t "SirF binary" -D 4 /dev/ttyUSB0
but still getting the same response with one extra line in the output,
gpsctl:ERROR: no driver type name matches 'SirF binary'.
as i mentioned above that sometimes it successfuly recognizes the device type (which is SiRF binary) and baud rate (which is 4800), in such cases of success it converts the mode to NMEA
Is the command case-sensitive?
Should it be SiRF?
It has been my custom to use Xeyes

Return to “Python”