Skip to content

Commit

Permalink
Merge pull request #154 from brickbots/gps_timeloc_split
Browse files Browse the repository at this point in the history
Look for time signal across all valid GPS packets
  • Loading branch information
brickbots authored Mar 9, 2024
2 parents 1245204 + 0339578 commit 8219077
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions python/PiFinder/gps_pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def gps_monitor(gps_queue, console_queue):
readings_list = list(islice(readings_filter, 10))
if readings_list:
result = min(
readings_list, key=lambda x: x.get("ecefpAcc", float("inf"))
readings_list,
key=lambda x: x.get("ecefpAcc", x.get("sep", float("inf"))),
)
logging.debug("last reading is %s", result)
if result.get("lat") and result.get("lon") and result.get("altHAE"):
Expand All @@ -53,10 +54,14 @@ def gps_monitor(gps_queue, console_queue):
)
logging.debug("GPS fix: %s", msg)
gps_queue.put(msg)
if result.get("time"):
msg = ("time", result.get("time"))
logging.debug("Setting time to %s", result.get("time"))
gps_queue.put(msg)

# Look for any time bearing packet
for result in readings_list:
if result.get("time"):
msg = ("time", result.get("time"))
logging.debug("Setting time to %s", result.get("time"))
gps_queue.put(msg)
break
else:
logging.debug("GPS client queue is empty")
logging.debug("GPS sleeping now")
Expand Down

0 comments on commit 8219077

Please sign in to comment.