Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added decoding of 'PGTOP' to get the status of the antenna extension …
…(if any).

The antenna status is made accessible via the new 'self.antenna' property.
A tuple (current status, last status). Possible values are:
1: Antenna shorted.
2: Internal antenna.
3: Active (extending) antenna.

So self.antenna[0] gives the current status and self.antenna[1] gives the
last status. User is responsible to acknowledge change in the antenna
status by making self.antenna[1] same as item 0.
  • Loading branch information
PierreDeQuebec committed Dec 30, 2022
commit c985cfeb0c818648472ea93ccbc5d91581e48d4e
17 changes: 16 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 (added by Pierre Lepage)
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. Added by Pierre Lepage.
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,17 @@ 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 Expand Up @@ -747,3 +761,4 @@ def readline(self) -> Optional[bytearray]:
self._internalbuffer = [] # reset the buffer to empty
return ret
return None # no completed data yet