From 3f593e66496953f360c8856c4b4fe6e61a9d86e4 Mon Sep 17 00:00:00 2001 From: cintom00 Date: Wed, 31 Jan 2018 17:19:26 +0100 Subject: [PATCH 1/4] Added supported sentences for Beitian GPS-module The Beitian BN-880 appears to use slightly different NEMA sentences. By adding these sentences and calling the methods which already exist everything seems to work as expected. This was tested on an ESP32. The extra exception catching was needed to prevent the program from crashing in case a "list index out of range" exception was thrown. --- micropyGPS.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/micropyGPS.py b/micropyGPS.py index 619190c..a4ce284 100644 --- a/micropyGPS.py +++ b/micropyGPS.py @@ -497,21 +497,29 @@ class MicropyGPS(object): sat_id = int(self.gps_segments[sats]) except ValueError: return False + except Exception: + return False try: # elevation can be null (no value) when not tracking elevation = int(self.gps_segments[sats+1]) except ValueError: elevation = None + except Exception: + elevation = None try: # azimuth can be null (no value) when not tracking azimuth = int(self.gps_segments[sats+2]) except ValueError: azimuth = None + except Exception: + azimuth = None try: # SNR can be null (no value) when not tracking snr = int(self.gps_segments[sats+3]) except ValueError: snr = None + except Exception: + snr = None # If no PRN is found, then the sentence has no more satellites to read else: @@ -809,6 +817,8 @@ class MicropyGPS(object): 'GPGSA': gpgsa, 'GLGSA': gpgsa, 'GPGSV': gpgsv, 'GLGSV': gpgsv, 'GPGLL': gpgll, 'GLGLL': gpgll, + 'GNGGA': gpgga, 'GNRMC': gprmc, + 'GNVTG': gpvtg, } if __name__ == "__main__": From cdd37a0ff73605d3ecc130f64552a2d6d215a685 Mon Sep 17 00:00:00 2001 From: cintom00 Date: Wed, 31 Jan 2018 17:41:26 +0100 Subject: [PATCH 2/4] Updated README and added ESP32 instructions part All supported sentences are now in the README file and also a small part on how to use it with an ESP32. --- README.md | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ea815d5..97b8fe0 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ Features: - Parser written with a serial UART data source in mind; works on a single character at a time with robust error handling for noisy embedded environments - Modeled after the great [TinyGPS] Arduino library - - + + ## Basic Usage micropyGPS is easy to use: copy micropyGPS.py into your project directory and import the MicropyGPS class into your script. From @@ -38,15 +38,23 @@ The object will continue to accept new characters and parse sentences for as lon $ python tests.py ``` -### Currently Supported Sentences +### Currently Supported Sentences * GPRMC +* GLRMC +* GNRMC * GPGLL +* GLGLL * GPGGA +* GLGGA +* GNGGA * GPVTG +* GLVTG +* GNVTG * GPGSA +* GLGSA * GPGSV - +* GLGSV ### Position Data Data successfully parsed from valid sentences is stored in easily accessible object variables. Data with multiple components (like latitude and longitude) is stored in tuples. @@ -91,7 +99,7 @@ The timezone can be automatically adjusted for using the by setting the ```local (3, 18, 36.0) ``` -The current UTC date is stored (day,month,year). **NOTE:** The date is not currently adjusted to match the timezone set in ```local_offset```. +The current UTC date is stored (day,month,year). **NOTE:** The date is not currently adjusted to match the timezone set in ```local_offset```. ```sh >>> my_gps.date (22, 9, 05) @@ -120,7 +128,7 @@ Signal quality and individual satellite information is collected from GSV, GSA, >>> my_gps.satellite_data_updated() True # Satellite data is a dict where the key is the satellite number and the value pair is a tuple containing (Elevation, Azimuth, SNR (if available)) ->>> my_gps.satellite_data +>>> my_gps.satellite_data {19: (5, 273, None), 32: (5, 303, None), 4: (22, 312, 26), 11: (9, 315, 16), 12: (19, 88, 23), 14: (64, 296, 22), 15: (2, 73, None), 18: (54, 114, 21), 51: (40, 212, None), 21: (16, 175, None), 22: (81, 349, 25), 24: (30, 47, 22), 25: (17, 127, 18), 31: (22, 204, None)} # Returns just the satellite PRNs visible >>> my_gps.satellites_visible() @@ -194,18 +202,22 @@ Test scripts are included to help get started with using micropyGPS on the [pybo Adjusting the baud rate and update rate of the receiver can be easily accomplished with my companion [MTK_command] script -An example of how to hookup the pyboard to the Adafruit [Ultimate GPS Breakout] (minus the PPS signal needed in the external interrupt example) is shown below. +An example of how to hookup the pyboard to the Adafruit [Ultimate GPS Breakout] (minus the PPS signal needed in the external interrupt example) is shown below. -![hookup](http://i.imgur.com/yd4Mjka.jpg?1) +![hookup](http://i.imgur.com/yd4Mjka.jpg?1) + +## ESP32 +You can follow the setup instructions for the pyboard. The only difference is, that you shoud use micropyGPS as a [frozen module]. Otherwise there will be exceptions, because there is not enough heap space available. ## Other Platforms -As mentioned above, micropyGPS also runs on Python3.x (that's where most of the development was done!). This is useful for testing code or just parsing existing log files. +As mentioned above, micropyGPS also runs on Python3.x (that's where most of the development was done!). This is useful for testing code or just parsing existing log files. -Beyond the pyBoard, micropyGPS should run on other embedded platforms that have an Python3 interpreter such as the Raspberry Pi and BeagleBone boards. These other devices are currently untested. +Beyond the pyBoard and ESP32, micropyGPS should run on other embedded platforms that have an Python3 interpreter such as the Raspberry Pi and BeagleBone boards. These other devices are currently untested. [Micropython]:https://micropython.org/ +[frozen module]:https://learn.adafruit.com/micropython-basics-loading-modules/frozen-modules [NMEA-0183]:http://aprs.gids.nl/nmea/ -[TinyGPS]:http://arduiniana.org/libraries/tinygps/ +[TinyGPS]:http://arduiniana.org/libraries/tinygps/ [pyboard]:http://docs.micropython.org/en/latest/pyboard/pyboard/quickref.html [MTK_command]:https://github.com/inmcm/MTK_commands -[Ultimate GPS Breakout]:http://www.adafruit.com/product/746 \ No newline at end of file +[Ultimate GPS Breakout]:http://www.adafruit.com/product/746 From 564031ffd392816b9391b9a41a260638ee3ad65f Mon Sep 17 00:00:00 2001 From: cintom00 Date: Sun, 4 Feb 2018 10:33:54 +0100 Subject: [PATCH 3/4] Changed exception handling and removed whitespaces The whitespaces which were removed and messed up the git history were added again. Instead of catching all exceptions, we just now just catch the IndexError. --- README.md | 2 +- micropyGPS.py | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 97b8fe0..b1e308d 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ Beyond the pyBoard and ESP32, micropyGPS should run on other embedded platforms [Micropython]:https://micropython.org/ [frozen module]:https://learn.adafruit.com/micropython-basics-loading-modules/frozen-modules [NMEA-0183]:http://aprs.gids.nl/nmea/ -[TinyGPS]:http://arduiniana.org/libraries/tinygps/ +[TinyGPS]:http://arduiniana.org/libraries/tinygps/ [pyboard]:http://docs.micropython.org/en/latest/pyboard/pyboard/quickref.html [MTK_command]:https://github.com/inmcm/MTK_commands [Ultimate GPS Breakout]:http://www.adafruit.com/product/746 diff --git a/micropyGPS.py b/micropyGPS.py index a4ce284..75345c3 100644 --- a/micropyGPS.py +++ b/micropyGPS.py @@ -495,32 +495,23 @@ class MicropyGPS(object): if self.gps_segments[sats]: try: sat_id = int(self.gps_segments[sats]) - except ValueError: - return False - except Exception: + except (ValueError,IndexError): return False try: # elevation can be null (no value) when not tracking elevation = int(self.gps_segments[sats+1]) - except ValueError: - elevation = None - except Exception: + except (ValueError,IndexError): elevation = None try: # azimuth can be null (no value) when not tracking azimuth = int(self.gps_segments[sats+2]) - except ValueError: - azimuth = None - except Exception: + except (ValueError,IndexError): azimuth = None try: # SNR can be null (no value) when not tracking snr = int(self.gps_segments[sats+3]) - except ValueError: + except (ValueError,IndexError): snr = None - except Exception: - snr = None - # If no PRN is found, then the sentence has no more satellites to read else: break From 8ace241f1ddf9561d581539cc08643fbe658c4e3 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 4 Feb 2018 10:45:01 +0100 Subject: [PATCH 4/4] Fixed git history for Readme file * Added missing whitspaces --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b1e308d..1872f44 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ Features: - Parser written with a serial UART data source in mind; works on a single character at a time with robust error handling for noisy embedded environments - Modeled after the great [TinyGPS] Arduino library - - + + ## Basic Usage micropyGPS is easy to use: copy micropyGPS.py into your project directory and import the MicropyGPS class into your script. From @@ -38,7 +38,7 @@ The object will continue to accept new characters and parse sentences for as lon $ python tests.py ``` -### Currently Supported Sentences +### Currently Supported Sentences * GPRMC * GLRMC @@ -56,6 +56,7 @@ $ python tests.py * GPGSV * GLGSV + ### Position Data Data successfully parsed from valid sentences is stored in easily accessible object variables. Data with multiple components (like latitude and longitude) is stored in tuples. ```sh @@ -99,7 +100,7 @@ The timezone can be automatically adjusted for using the by setting the ```local (3, 18, 36.0) ``` -The current UTC date is stored (day,month,year). **NOTE:** The date is not currently adjusted to match the timezone set in ```local_offset```. +The current UTC date is stored (day,month,year). **NOTE:** The date is not currently adjusted to match the timezone set in ```local_offset```. ```sh >>> my_gps.date (22, 9, 05) @@ -128,7 +129,7 @@ Signal quality and individual satellite information is collected from GSV, GSA, >>> my_gps.satellite_data_updated() True # Satellite data is a dict where the key is the satellite number and the value pair is a tuple containing (Elevation, Azimuth, SNR (if available)) ->>> my_gps.satellite_data +>>> my_gps.satellite_data {19: (5, 273, None), 32: (5, 303, None), 4: (22, 312, 26), 11: (9, 315, 16), 12: (19, 88, 23), 14: (64, 296, 22), 15: (2, 73, None), 18: (54, 114, 21), 51: (40, 212, None), 21: (16, 175, None), 22: (81, 349, 25), 24: (30, 47, 22), 25: (17, 127, 18), 31: (22, 204, None)} # Returns just the satellite PRNs visible >>> my_gps.satellites_visible() @@ -210,7 +211,7 @@ An example of how to hookup the pyboard to the Adafruit [Ultimate GPS Breakout] You can follow the setup instructions for the pyboard. The only difference is, that you shoud use micropyGPS as a [frozen module]. Otherwise there will be exceptions, because there is not enough heap space available. ## Other Platforms -As mentioned above, micropyGPS also runs on Python3.x (that's where most of the development was done!). This is useful for testing code or just parsing existing log files. +As mentioned above, micropyGPS also runs on Python3.x (that's where most of the development was done!). This is useful for testing code or just parsing existing log files. Beyond the pyBoard and ESP32, micropyGPS should run on other embedded platforms that have an Python3 interpreter such as the Raspberry Pi and BeagleBone boards. These other devices are currently untested.