Commit d1897775 authored by James Browning's avatar James Browning
Browse files

ntploggps: Resolve issue #730 by ensuring relevant fields valid.

gpsd appears to be sending SKY sentences without satellites[].
gpsd also appears to be (sometimes) 'uSat' which has the number.
So, grab 'device', 'tdop' and (the sum of used satellites[] or 'uSat').
Check that non of them are invalid, then package them for use.

Also, address potential issue where on multi-device systems,
another device can steal the thunder of the reporting device.
That however, can never occur.
parent cfa361c4
Pipeline #482658641 passed with stages
in 5 minutes and 34 seconds
......@@ -159,14 +159,28 @@ class GpsPoller(threading.Thread):
self.running = False
break
if hasattr(self.gpsd, "data"):
if self.gpsd.data.get("class") == "SKY":
self.satellites_used = 0
self.tdop = self.gpsd.data.get("tdop", 0)
for sat in self.gpsd.data.get("satellites", []):
if sat["used"]:
self.satellites_used += 1
elif self.gpsd.data.get("class") == "TPV":
self.device = self.gpsd.data.get("device")
if self.gpsd.data.get("class", None) == "SKY":
satellite_list = self.gpsd.data.get(
"satellites", None
)
if satellite_list is not None:
count_used_satellites = sum(
map(lambda x: x.used, satellite_list)
)
time_dilution = self.gpsd.data.get("tdop", None)
device_path = self.gpsd.data.get("device", None)
if count_used_satellites is None:
count_used_satellites = self.gpsd.data.get(
"uSat", None
)
if None not in [
count_used_satellites,
time_dilution,
device_path,
]:
self.satellites_used = count_used_satellites
self.tdop = time_dilution
self.device = device_path
@property
def time(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment