I'll be brief: I have a u-blox M8 GNSS evaluation kit, and I'm trying to pull location data from it as a sub-routine in a larger program. But I'm being stumped at the outset. My program terminates while trying to establish the initial connection with the following error:
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
I thought maybe another process was listening on the default port for gpsd (2947), but after calling 'netstat -a -n' (in windows command prompt) I was able to confirm that no other processes were blocking the port. I don't know how to further pursue what the causes could be, and would be eager for any suggestions more experienced users might have.
Edited to add more context for the lazy The program breaks off during the connect call (literally the first line of my own program), which you can see below for context:
def connect(host="127.0.0.1", port=2947):
""" Connect to a GPSD instance
:param host: hostname for the GPSD server
:param port: port for the GPSD server
"""
global gpsd_socket, gpsd_stream, verbose_output, state
logger.debug("Connecting to gpsd socket at {}:{}".format(host, port))
gpsd_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
gpsd_socket.connect((host, port))
gpsd_stream = gpsd_socket.makefile(mode="rw")
logger.debug("Waiting for welcome message")
welcome_raw = gpsd_stream.readline()
welcome = json.loads(welcome_raw)
if welcome['class'] != "VERSION":
raise Exception(
"Unexpected data received as welcome. Is the server a gpsd 3 server?")
logger.debug("Enabling gps")
gpsd_stream.write('?WATCH={"enable":true}\n')
gpsd_stream.flush()
for i in range(0, 2):
raw = gpsd_stream.readline()
parsed = json.loads(raw)
_parse_state_packet(parsed)