Turning the GPS up to 10(Hz)!
Until today I had been using the Adafruit Ultimate GPS pretty much straight out of the box. This meant that it was running at 9600 BAUD, with 1Hz updates, including the satellite SKY records. That's a whole lot of data to send over a 9600 BAUD serial line. In practice that meant that NTP wasn't very happy with the GPS output, and one update per second was nowhere near enough for logging data on a motorcycle travelling at 100+mph (on the track of course).
The GPS is capable of 1/5/10Hz updates, but defaults to 1Hz. It's also capable of BAUD rates up to 115200, but defaults to 9600. In order to increase the update frequency, you really have to push the BAUD much higher. A number of people also recommend dropping the SKY records to reduce the throughput. I looked into this and, unlike some microcontrollers, the Raspberry Pi is quite happy with 115200 BAUD, so the SKY records get to stay for now!
All you need to do to change the BAUD rate is to send the GPS the appropriate command and it will respond with a confirmation string. Same again for the 10Hz updates. The NMEA sentences that you need to send are well documented in the PDF. You need is a checksum generator to find the magic characters for the end of the sentence, and after that, it's a simple bit of Python code to access the serial port and send the relevant commands.
The GPS is capable of 1/5/10Hz updates, but defaults to 1Hz. It's also capable of BAUD rates up to 115200, but defaults to 9600. In order to increase the update frequency, you really have to push the BAUD much higher. A number of people also recommend dropping the SKY records to reduce the throughput. I looked into this and, unlike some microcontrollers, the Raspberry Pi is quite happy with 115200 BAUD, so the SKY records get to stay for now!
All you need to do to change the BAUD rate is to send the GPS the appropriate command and it will respond with a confirmation string. Same again for the 10Hz updates. The NMEA sentences that you need to send are well documented in the PDF. You need is a checksum generator to find the magic characters for the end of the sentence, and after that, it's a simple bit of Python code to access the serial port and send the relevant commands.
#!/usr/bin/python
from serial import Serial
import time
outStr = ''
inStr = ''
serialPort = Serial("/dev/ttyAMA0", 9600, timeout=2)
if (serialPort.isOpen() == False):
serialPort.open()
serialPort.flushInput()
serialPort.flushOutput()
outStr = '$PMTK251,115200*1F\r\n'
print "outStr = " + outStr
serialPort.write(outStr)
time.sleep(0.1)
inStr = serialPort.read(serialPort.inWaiting())
print "inStr = " + inStr
serialPort.close()
serialPort = Serial("/dev/ttyAMA0", 115200, timeout=2)
if (serialPort.isOpen() == False):
serialPort.open()
serialPort.flushInput()
serialPort.flushOutput()
outStr = '$PMTK220,100*2F\r\n'
print "outStr = " + outStr
serialPort.write(outStr)
time.sleep(0.1)
inStr = serialPort.read(serialPort.inWaiting())
print "inStr = " + inStr
serialPort.close()