-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
The sample code below is currently returned as the top search result for python gps. It's hosted at this URL https://pypi.org/project/gps3/ and the big problem here is that the loop runs out of control, trashing the CPU usage for no reason. I would recommend adding a sleep to the loop. Quite simply a "time.sleep(0.2)" just below the "for new_data in ..." line would save a ton of carbon as N00bs using the sample code don't end up with code that max's out their CPU with useless looping.
from gps3 import gps3
gps_socket = gps3.GPSDSocket()
data_stream = gps3.DataStream()
gps_socket.connect()
gps_socket.watch()
for new_data in gps_socket:
if new_data:
data_stream.unpack(new_data)
print('Altitude = ', data_stream.TPV['alt'])
print('Latitude = ', data_stream.TPV['lat'])
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels