Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import serial
- import time
- ser = serial.Serial('/dev/ttyS0') #åbner port.
- running = True
- try:
- while running:
- data = ser.readline()
- #print(data)
- for line in data.split(b'\n'):
- if line.startswith(b'$GPGGA'):
- line = str(line.decode("UTF-8"))
- line = line.split(",")
- latitude = line[2]
- north = line[3]
- longtitude = line[4]
- east = line[5]
- gps = latitude + north + " " + longtitude + east
- lat_b = float(latitude[2:8]) / 60
- lat_a = float(latitude[0:2])
- print(lat_a + lat_b)
- long_b = float(longtitude[3:9]) / 60
- long_a = float(longtitude[0:3])
- print(long_b + long_a)
- print(gps)
- except KeyboardInterrupt:
- print("program lukker")
- running = False
- ser.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement