/
gps_hardware_test.py
113 lines (75 loc) · 2.56 KB
/
gps_hardware_test.py
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env python
########################################################################
# This example is for is the simplest GPS Script. It simply reads the
# raw output of the GPS sensor on the GoPiGo or GrovePi and prints it.
#
# http://www.dexterindustries.com/GoPiGo/
# http://www.dexterindustries.com/GrovePi/
# History
# ------------------------------------------------
# Author Date Comments
# John 2/25/2015 Initial Authoring
#
# These files have been made available online through a Creative Commons Attribution-ShareAlike 3.0 license.
# (http://creativecommons.org/licenses/by-sa/3.0/)
#
########################################################################
from gopigo import *
import serial, time
import smbus
import math
import RPi.GPIO as GPIO
import struct
import sys
import ir_receiver_check
if ir_receiver_check.check_ir():
print "Disable IR receiver before continuing"
exit()
ser = serial.Serial('/dev/ttyAMA0', 9600, timeout = 0) #Open the serial port at 9600 baud
ser.flush()
def readlineCR():
rv = ""
while True:
time.sleep(0.01) # This is the critical part. A small pause
# works really well here.
ch = ser.read()
rv += ch
if ch=='\r' or ch=='':
return rv
while True:
#readlineCR()
x=readlineCR()
print x
########################################################################
#
# The output should look like something below.
#
#
########################################################################
'''
$GPGGA,001929.799,,,,,0,0,,,M,,M,,*4C
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPRMC,001929.799,V,,,,,0.00,0.00,060180,,,N*46
$GPGGA,001930.799,,,,,0,0,,,M,,M,,*44
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPRMC,001930.799,V,,,,,0.00,0.00,060180,,,N*4E
$GPGGA,001931.799,,,,,0,0,,,M,,M,,*45
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPRMC,001931.799,V,,,,,0.00,0.00,060180,,,N*4F
$GPGGA,001932.799,,,,,0,0,,,M,,M,,*46
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPRMC,001932.799,V,,,,,0.00,0.00,060180,,,N*4C
$GPGGA,001933.799,,,,,0,0,,,M,,M,,*47
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPRMC,001933.799,V,,,,,0.00,0.00,060180,,,N*4D
$GPGGA,001934.799,,,,,0,0,,,M,,M,,*40
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPRMC,001934.799,V,,,,,0.00,0.00,060180,,,N*4A
$GPGGA,001935.799,,,,,0,0,,,M,,M,,*41
'''