Changing update speed with gpsd and python

I am using adafruit GPS interrupt with my raspberry Pi 2 using python2.7.9, GPSD and the python-gps package. I am successfully receiving gps updates at 1 Hz on a serial port.

Perhaps this device supports 10 Hz updates that I would like to enable. According to the data table (see below below), this can be set using a serial command.

enter image description here

My problem is that I cannot find enough documentation for the python-gps or GPSD module, which will tell me how I should send commands to GPS via the serial port with my python script. Can someone point me in the right direction?

+7
python gps raspberry-pi2 gpsd
source share
1 answer

I just took gps from the same family as yours. (MTK) They use the $PMTK control lines. Any search for the PMTK protocol provides endless resources. The limit is gps itself.

For a one-time conversion, the standard method is executed from the root terminal execute echo -e "\$PMTK220,200*2C\r\n" > /dev/ttyAMA0 or wherever the device is connected, for a 5 Hz response.

  • -e flag allows parsing backslashes
  • $ Start of NMEA sentence
  • P Proprietary message
  • MTK NMEA Data Type
  • 220 Package Type
  • 200 Package Data
  • * End of data
  • 2C checksum
  • \r\n End of NMEA clause

There are scripts and other projects , but all require that gpsd does not control gps. Gpsd will prevent the sending of a control line in gps.

Also, if you have the -b flag in /etc/default/gpsd , gpsd will not be written to the device when it is connected. He will choose the general NMEA driver and will not write any control lines in gps.

You can slip behind and control the speed using control lines from the shell. GPS will spew data, but GPS does not recognize speed.

Gpsd seems to prefer 1 second sync. Even if gps is capable of performing faster cycles, even if you have already used other methods to redial / set the speed, while gpsd needs to be informed that the speed has changed.

This uses gpsctl -c 0.2 (no sudo). It comes in a gpsd package.

If only one device is connected in gpsd, in this example gpsctl will change this device by 0.2 seconds of a cycle and transfer it to gpsd. Time in seconds. Yes, it can be installed quite slowly / quickly, but there is no possibility of fake. If he cannot do this, he will not do this and will not report that he does not / cannot, if there is no fatal error.

Port speed is not a problem if there is capacity. The one who counted once said that 4800 baud is enough to read data in one second, which is required to send data. It depends on the payload, but it works for a rule of thumb. 10Hz can cause a default of 38,400 baud in many systems. I tried and nothing broke.

You just want to make sure gpsd doesn't agree on 9600 bauds before you can increase the speed, just in case. gpsctl -s XXXX (to set the baud rate at which GPS emits packets) returns an error for me.

Even without the -b flag in the default gpsd setting, this new gps does not remain fixed in higher frequency updates between shutdowns. I have to re-execute the command. It can be a bad battery, an operator error, or I don’t understand that this defect is a function that allows not to click gps out of reach for other systems. (Reason for -b )

This is how you modify the response from gps that uses gpsd, or how I did it.

However, answering your question to change gps response speed through gpsd using Python

 import subprocess subprocess.call(['gpsctl', '-c', '0.2']) # Digits are the time in seconds. 

Try and see. Using gpsctl -c 0.25 returns quarter-second gps readings, etc.

To help two python gpsd demonstration scenarios to which I just added a gpsd device message, refresh the keystroke (Hit d to refresh and see the numbers from the new setting.)

They are designed for Python 2.7-3.5 gpsd python client , when a function finds a home in demo scripts, it will look something like this:

 def hertz(hz): """Change or enumerate a Faster/Slower gps refresh rate if device is able""" from subprocess import call inverse = str(1 / hz) call((['gpsctl', '-c', inverse])) 
+4
source share

All Articles