Skip to content

Commit

Permalink
Removed RMC since it would sometime produce duplicate lat long fixes #41
Browse files Browse the repository at this point in the history
. Took a stab at macos identification of gps, working on #38.
  • Loading branch information
micahjohnson150 committed Dec 8, 2023
1 parent 412a83e commit 8e8ca42
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions radicl/gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class USBGPS:
def __init__(self, debug=False):
self.log = get_logger(__name__, debug=debug)
try:
self.cnx = get_serial_cnx('u-blox')
self.cnx = get_serial_cnx('blox')
except Exception as e:
self.cnx = None
self.log.error('Unable to open GPS port.')
Expand Down Expand Up @@ -40,7 +40,7 @@ def get_fix(self, max_attempts=20):
for i in range(max_attempts):
rx, msg = gps.read()

if msg.msgID in ['GGA', 'RMC']:
if msg.msgID in ['GGA']:
info = msg.lat, msg.lon
if all(info):
location = [float(p) for p in info]
Expand Down
3 changes: 3 additions & 0 deletions radicl/high_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ def main():
if location is not None:
meta['Latitude'] = location[0]
meta['Longitude'] = location[1]
# if a gps exists but were not able to get a fix, report back.
elif location is None and gps.cnx is not None:
log.warning("Unable to get GPS fix")

# Output the data to a datetime file
filename = cli.write_probe_data(ts, extra_meta=meta)
Expand Down
9 changes: 9 additions & 0 deletions tests/connected/test_connected_gps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from radicl.gps import USBGPS
import pytest
from . import gps_not_connected
Expand All @@ -11,5 +12,13 @@ def gps_dev(self):

def test_get_fix(self, gps_dev):
location = gps_dev.get_fix(max_attempts=30)

assert len(location) == 2

def test_get_fix_not_identical(self, gps_dev):
""" Even a static GPS should be slightly different."""
location = gps_dev.get_fix(max_attempts=30)
time.sleep(0.5)
location2 = gps_dev.get_fix(max_attempts=30)

assert location != location2

0 comments on commit 8e8ca42

Please sign in to comment.