Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. from time import sleep
  2. import gps3
  3.  
  4. the_connection = gps3.GPSDSocket()
  5. the_fix = gps3.DataStream()
  6.  
  7. try:
  8. for new_data in the_connection:
  9. if new_data:
  10. the_fix.refresh(new_data)
  11. if not isinstance(the_fix.TPV['lat'], str): # check for valid data
  12. speed = the_fix.TPV['speed']
  13. latitude = the_fix.TPV['lat']
  14. longitude = the_fix.TPV['lon']
  15. altitude = the_fix.TPV['alt']
  16. print('Latitude:', latitude, 'Longitude:', longitude)
  17. sleep(1)
  18. except KeyboardInterrupt:
  19. the_connection.close()
  20. print("\nTerminated by user\nGood Bye.\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement