Hi everyone,
I’m trying to read data from a GPS device:
#!/usr/bin/env python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('127.0.0.1', 2947))
while True:
data = sock.recv(10240).decode().strip()
if len(data) == 0:
print("No data!")
else:
print(data)
I get the output: {“class”:“VERSION”,“release”:“3.22”,“rev”:“3.22”,“proto_major”:3,“proto_minor”:14}
but no more. gpsmon connects to the address 127.0.0.1:2947 and displays data.
What could be the problem?
It might just be that it reports the version when you connect to it, but tells you the coordinates only on demand. You’ll have to check the documentation to see what’s required.
Why should there be more data? What do you expect the rest of the data to look like, and why? Did you try to look up and read any documentation in order to understand how this works? (For example, are you expecting it to send you everything all at once? What is “everything”, anyway? Or should it periodically send you new information, or just what?)