From 083dae809550ea9ebaa88f2b3b94d3b5f22d37d7 Mon Sep 17 00:00:00 2001 From: inmcm Date: Mon, 15 Dec 2014 18:45:36 -0500 Subject: [PATCH] Add pyboard compatible test scripts --- pyboard/sentence_test.py | 26 ++++++++++++++++++++++++++ pyboard/uart_test.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 pyboard/sentence_test.py create mode 100644 pyboard/uart_test.py diff --git a/pyboard/sentence_test.py b/pyboard/sentence_test.py new file mode 100644 index 0000000..f8e301f --- /dev/null +++ b/pyboard/sentence_test.py @@ -0,0 +1,26 @@ +# micropyGPS Sentence Test +# When properly connected to working GPS module, +# will print the names of the sentences it receives +# If you are having issues receiving sentences, use UART_test.py to ensure +# your UART is hooked up and configured correctly + +from pyb import UART +from micropyGPS import MicropyGPS + +# Setup the connection to your GPS here +# This example uses UART 3 with RX on pin Y10 +# Baudrate is 9600bps, with the standard 8 bits, 1 stop bit, no parity +uart = UART(3, 9600) + +# Instatntiate the micropyGPS object +my_gps = MicropyGPS() + +# Continuous Tests for characters available in the UART buffer, any characters are feed into the GPS +# object. When enough char are feed to represent a whole, valid sentence, stat is set as the name of the +# sentence and printed +while True: + if uart.any(): + stat = my_gps.update(chr(uart.readchar())) # Note the conversion to to chr, UART outputs ints normally + if stat: + print(stat) + stat = None diff --git a/pyboard/uart_test.py b/pyboard/uart_test.py new file mode 100644 index 0000000..e312234 --- /dev/null +++ b/pyboard/uart_test.py @@ -0,0 +1,29 @@ +from pyb import UART +from micropyGPS import MicropyGPS + +uart = UART(3, 9600) + +# Basic UART --> terminal printer, use to test your GPS module +# while True: +# if uart.any(): +# print(chr(uart.readchar()), end='') + + +my_gps = MicropyGPS() + +sentence_count = 0 +while True: + if uart.any(): + stat = my_gps.update(chr(uart.readchar())) + if stat: + print(stat) + stat = None + sentence_count += 1 + if sentence_count == 300: + break; + + +print('Sentences Found:', my_gps.clean_sentences) +print('Sentences Parsed:', my_gps.parsed_sentences) +print('CRC_Fails:', my_gps.crc_fails) +