Serial GPS data reading utility

Serial usb gps deviceses can be used trought serial consoles or some other libraries. From shell need some basic configuaration at begining to use serial device from shell. This command provide simple way how to do it. This code opens /dev/tty* device, setup baud rate to 4800 and outputs line by line recieved data. When device connected ther could be that is not in NMEA mode it could be switched with:

gpsctl -n /dev/ttyUSB0

Then you can connect with it with some serial terminal(dont forget baudrate could be 4800 or 9600):

minicom -D /dev/ttyUSB0

Now we can use our gpsr utility

./gpsr -d /dev/ttyUSB0 -c 0
./gpsr -d /dev/ttyACM0 -c 1

NMEA format is csv like and it easyly can be used from shell. Here is exmple how it looks:

$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A

Where: RMC Recommended Minimum sentence C 123519 Fix taken at 12:35:19 UTC A Status A=active or V=Void. 4807.038,N Latitude 48 deg 07.038' N 01131.000,E Longitude 11 deg 31.000' E 022.4 Speed over the ground in knots 084.4 Track angle in degrees True 230394 Date - 23rd of March 1994 003.1,W Magnetic Variation 6A The checksum data, always begins with

Get time from GPS

./gpsr -d /dev/ttyUSB0 -c 100 | stdbuf -o0 grep -w "GPRMC" | cut -d',' -f2

REQUIREMENTS

GCC C, minicom, shell, GPS device

TESTED

I have tested everything with GPS devices BU-353 and with some device that havenot any visual marks but have chip from u-blox manufacturer.

COMPILE:

gcc buf.c -c
gcc serial_tty.c -c
gcc serial_tty.o buf.o gpsr.c -o gpsr

TODO:

there could be added baudrate set as params loging in csv,xml,json files make longterm test for stability

Links

http://en.wikipedia.org/wiki/NMEA_0183
http://www.gpsinformation.org/dale/nmea.htm
http://home.mira.net/~gnb/gps/nmea.html
http://linux.die.net/man/1/minicom

Downloads

gpsr.tar.gz - 3KiB - http://archive.main.lv/files/writeup/serial_gps_data_reading_utility/gpsr.tar.gz