From dcf558b8e137c539ede20449f549323ffbcd6967 Mon Sep 17 00:00:00 2001 From: Cefn Hoile Date: Mon, 26 Feb 2018 20:16:17 +0000 Subject: [PATCH 1/2] Fix micropython issue from secs sometimes being a float after remainder operation --- adafruit_gps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_gps.py b/adafruit_gps.py index 097a559..3e40bcd 100644 --- a/adafruit_gps.py +++ b/adafruit_gps.py @@ -152,7 +152,7 @@ def _parse_gpgga(self, args): if time_utc is not None: hours = time_utc // 10000 mins = int((time_utc // 100) % 100) - secs = time_utc % 100 + secs = int(time_utc % 100) # Set or update time to a friendly python time struct. if self.timestamp_utc is not None: self.timestamp_utc = time.struct_time(( @@ -188,7 +188,7 @@ def _parse_gprmc(self, args): if time_utc is not None: hours = time_utc // 10000 mins = int((time_utc // 100) % 100) - secs = time_utc % 100 + secs = int(time_utc % 100) # Set or update time to a friendly python time struct. if self.timestamp_utc is not None: self.timestamp_utc = time.struct_time(( From 559222c5b495f11a153b36579ae29c26e8b49170 Mon Sep 17 00:00:00 2001 From: Cefn Hoile Date: Tue, 27 Feb 2018 02:05:46 +0000 Subject: [PATCH 2/2] Addressed issue with floor division still permitting floats through in the hour field. --- adafruit_gps.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/adafruit_gps.py b/adafruit_gps.py index 3e40bcd..a6a21de 100644 --- a/adafruit_gps.py +++ b/adafruit_gps.py @@ -148,11 +148,11 @@ def _parse_gpgga(self, args): if data is None or len(data) != 14: return # Unexpected number of params. # Parse fix time. - time_utc = _parse_float(data[0]) + time_utc = int(_parse_float(data[0])) if time_utc is not None: hours = time_utc // 10000 - mins = int((time_utc // 100) % 100) - secs = int(time_utc % 100) + mins = (time_utc // 100) % 100 + secs = time_utc % 100 # Set or update time to a friendly python time struct. if self.timestamp_utc is not None: self.timestamp_utc = time.struct_time(( @@ -184,11 +184,11 @@ def _parse_gprmc(self, args): if data is None or len(data) < 11: return # Unexpected number of params. # Parse fix time. - time_utc = _parse_float(data[0]) + time_utc = int(_parse_float(data[0])) if time_utc is not None: hours = time_utc // 10000 - mins = int((time_utc // 100) % 100) - secs = int(time_utc % 100) + mins = (time_utc // 100) % 100 + secs = time_utc % 100 # Set or update time to a friendly python time struct. if self.timestamp_utc is not None: self.timestamp_utc = time.struct_time((