Skip to content

Fix https://github.com/adafruit/Adafruit_CircuitPython_GPS/issues/105 #115

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 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion adafruit_gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
https://github.com/adafruit/circuitpython/releases

"""

import time
from micropython import const

Expand Down Expand Up @@ -61,7 +62,7 @@
# 0 - _GLL
"dcdcscC",
# 1 - _RMC
"scdcdcffsDCC",
"scDCDCFFsDCC",
# 2 - _GGA
"sdcdciiffsfsIS",
# 3 - _GSA
Expand Down Expand Up @@ -588,6 +589,7 @@ def _parse_rmc(self, data: List[str]) -> bool:
self.fix_quality = 1
else:
self.fix_quality = 0
return True # break early since no fix means no following values will be populated

# Latitude
self.latitude = _read_degrees(parsed_data, 2, "s")
Expand Down
12 changes: 12 additions & 0 deletions tests/adafruit_gps_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ def test_GPS_update_timestamp_timestamp_utc_was_not_none_new_date_none():
assert gps.timestamp_utc == exp_struct


def test_GPS_update_time_from_RTC_without_fix():
r = b"$GPRMC,210648.000,V,,,,,0.71,105.86,050425,,,N*4E\r\n"
with mock.patch.object(GPS, "readline", return_value=r):
gps = GPS(uart=UartMock())
gps.update()
exp_time = time.struct_time((2025, 4, 5, 21, 6, 48, 0, 0, -1))
assert gps.has_fix is False
assert gps.timestamp_utc == exp_time
assert gps.datetime == exp_time
assert gps.nmea_sentence == "$GPRMC,210648.000,V,,,,,0.71,105.86,050425,,,N*4E"


def test_GPS_update_with_unknown_talker():
r = b"$XYRMC,215032.086,A,1234.5678,N,00123.12345,E,0.45,56.35,021021,,,A*7c\r\n"
with mock.patch.object(GPS, "readline", return_value=r):
Expand Down