Skip to content

Commit

Permalink
Fix GPS over TCP connection error detection
Browse files Browse the repository at this point in the history
  • Loading branch information
EarToEarOak committed Mar 27, 2017
1 parent ec1f76a commit 183bb78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rtlsdr_scanner/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def __process_event(self, queue):
arg2[1],
arg2[2])
elif status == Event.LOC_ERR:
print '{}'.format(arg2)
print 'Error: {}'.format(arg2)
exit(1)

return status
Expand Down
9 changes: 6 additions & 3 deletions rtlsdr_scanner/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def __tcp_connect(self, defaultPort):
except socket.error as error:
post_event(self._notify, EventThread(Event.LOC_ERR,
0, error))
return False

return True

def __tcp_read(self, isGpsd=False):
buf = ''
Expand Down Expand Up @@ -179,7 +182,8 @@ def __serial_read(self):
time.sleep(0.1)

def __gpsd_open(self):
self.__tcp_connect(2947)
if not self.__tcp_connect(2947):
return False

try:
if self._device.type == DeviceGPS.GPSD:
Expand Down Expand Up @@ -249,8 +253,7 @@ def __nmea_open(self):
if self._device.type == DeviceGPS.NMEA_SERIAL:
return self.__serial_connect()
else:
self.__tcp_connect(10110)
return True
return self.__tcp_connect(10110)

def __nmea_read(self):
if self._device.type == DeviceGPS.NMEA_SERIAL:
Expand Down

0 comments on commit 183bb78

Please sign in to comment.