X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka.git/blobdiff_plain/ba4b66024f9426096195bfc78a84f2591a488efc..546aa0533b3270fb8922fc8fb1bc2419b5a7ed39:/test/src/testing/implementation/all/uart.py diff --git a/test/src/testing/implementation/all/uart.py b/test/src/testing/implementation/all/uart.py new file mode 100644 index 0000000..05a917f --- /dev/null +++ b/test/src/testing/implementation/all/uart.py @@ -0,0 +1,38 @@ +import gc +from unittest import TestCase +from testing import await_true +gc.collect() + + +class TestGPSInteractive(TestCase): + + def test_read_value(self): + import adafruit_blinka + adafruit_blinka.patch_system() # needed before adafruit_gps imports time + + import microcontroller.pin + gc.collect() + import busio + gc.collect() + import adafruit_gps + gc.collect() + + # configure the last available UART (first uart often for REPL) + uartId, uartTx, uartRx = microcontroller.pin.uartPorts[0] + uart = busio.UART(uartTx, uartRx, baudrate=9600, timeout=3000) + + gps = adafruit_gps.GPS(uart) + + gps.send_command('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') + gps.send_command('PMTK220,1000') + + def try_fix(): + gps.update() + return gps.has_fix + + await_true("GPS fix", try_fix) + + self.assertTrue(gps.satellites is not None) + self.assertTrue(-90 <= gps.latitude < 90) + self.assertTrue(-180 <= gps.longitude < 180) +