Skip to content

Commit

Permalink
Handled cases of no satellites seen
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoala committed Oct 13, 2017
1 parent f166c78 commit 1a2a62f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions gpsd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,14 @@ def from_json(cls, packet):
last_tpv = packet['tpv'][-1]
last_sky = packet['sky'][-1]

result.sats = len(last_sky['satellites'])
result.sats_valid = len(
[sat for sat in last_sky['satellites'] if sat['used'] == True])
if 'satellites' in last_sky:
result.sats = len(last_sky['satellites'])
result.sats_valid = len(
[sat for sat in last_sky['satellites'] if sat['used'] == True])
else:
result.sats = 0;
result.sats_valid = 0;

result.mode = last_tpv['mode']

if last_tpv['mode'] >= 2:
Expand Down

0 comments on commit 1a2a62f

Please sign in to comment.