]> Repositories - Adafruit_Blinka-hackapet.git/blobdiff - test/src/testing/implementation/all/uart.py
Definition of I2C bus-type per-board. Segregated busio tests into i2c vs uart
[Adafruit_Blinka-hackapet.git] / 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 (file)
index 0000000..05a917f
--- /dev/null
@@ -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)
+