Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import sleep
- import gps3
- the_connection = gps3.GPSDSocket()
- the_fix = gps3.DataStream()
- try:
- for new_data in the_connection:
- if new_data:
- the_fix.refresh(new_data)
- if not isinstance(the_fix.TPV['lat'], str): # check for valid data
- speed = the_fix.TPV['speed']
- latitude = the_fix.TPV['lat']
- longitude = the_fix.TPV['lon']
- altitude = the_fix.TPV['alt']
- print('Latitude:', latitude, 'Longitude:', longitude)
- sleep(1)
- except KeyboardInterrupt:
- the_connection.close()
- print("\nTerminated by user\nGood Bye.\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement