summaryrefslogtreecommitdiffstats
path: root/md/writeup/serial_gps_data_reading_utility.md
blob: 289c6108ee34bbe3d7c9938b45185d807b3395a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
title:Serial GPS data reading utility
keywords:gps,serial,uart,tty

# 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:

```sh
gpsctl -n /dev/ttyUSB0
```

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

```sh
minicom -D /dev/ttyUSB0
```

Now we can use our gpsr utility

```sh
./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:

```text
$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

```sh
./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

```sh
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