Skip to content

Added decoding of 'PGTOP' to get the status of the antenna extension … #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
15 changes: 14 additions & 1 deletion adafruit_gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def __init__(self, uart: UART, debug: bool = False) -> None:
self._uart = uart
# Initialize null starting values for GPS attributes.
self.timestamp_utc = None
self.antenna = (None, None) # Antenna status (current, last).
self.latitude = None
self.latitude_degrees = None
self.latitude_minutes = None # Use for full precision minutes
Expand Down Expand Up @@ -291,10 +292,12 @@ def update(self) -> bool:
# GP - GPS
# GQ - QZSS
# GN - GNSS / More than one of the above
# PG - Status of antenna extension
if talker not in (b"GA", b"GB", b"GI", b"GL", b"GP", b"GQ", b"GN"):
# It's not a known GNSS source of data
# Assume it's a valid packet anyway
return True
# False: PGTOP. Status of antenna extension.
return True if data_type[:5] != b"PGTOP" else self._parse_pgtop(args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion for clarity:

Suggested change
return True if data_type[:5] != b"PGTOP" else self._parse_pgtop(args)
return True if data_type.endswith(b"PGTOP") else self._parse_pgtop(args)


result = True
args = args.split(",")
Expand Down Expand Up @@ -676,6 +679,16 @@ def _parse_gsv(self, talker: bytes, data: List[str]) -> bool:

return True

def _parse_pgtop(self, data) -> int:
# Added by Pierre Lepage.
if data is None or len(data) != 4:
return False

# Antenna status. 1: Antenna shorted. 2: Internal antenna. 3: Active (extension) antenna.
# User can detect change in antenna status by testing equality between item 0 and item 1 of tuple.
# User is responsible to acknowledge change in the antenna status by making self.antenna[1] same as item 0.
self.antenna = (data[3], self.antenna[1])
return True

class GPS_GtopI2C(GPS):
"""GTop-compatible I2C GPS parsing module. Can parse simple NMEA data
Expand Down