forked from Space-Enterprise-at-Berkeley/Ground-Station
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPS_parse.py
More file actions
30 lines (20 loc) · 755 Bytes
/
Copy pathGPS_parse.py
File metadata and controls
30 lines (20 loc) · 755 Bytes
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
import serial
import csv
RFser = serial.Serial('COM3', 9600)
ser.flushInput()
while True:
try:
line = RFser.readline().strip()
data = line.split(',')
if(data[0] == "GPRMC"):
lat = data[3]
lat_dir = data[4]
lon = data[5]
lon_dir = data[6]
latitude = convert_to_decimal_degrees(int(lat[:2]), int(lat[2:]), 0)
longitude = convert_to_decimal_degrees(int(lon[:3]), int(lon[3:]), 0)
latitude *= -1 if lat_dir == 'S'
longitude *= -1 if lon_dir == 'W'
print("{},{}".format(latitude, longitude))
def convert_to_decimal_degrees(degrees, minutes, seconds):
return degrees + (minutes/60) + (seconds/3600)