]> Repositories - Adafruit_Blinka-hackapet.git/blob - 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
1 import gc
2 from unittest import TestCase
3 from testing import await_true
4 gc.collect()
5
6
7 class TestGPSInteractive(TestCase):
8
9     def test_read_value(self):
10         import adafruit_blinka
11         adafruit_blinka.patch_system() # needed before adafruit_gps imports time
12
13         import microcontroller.pin
14         gc.collect()
15         import busio
16         gc.collect()
17         import adafruit_gps
18         gc.collect()
19
20         # configure the last available UART (first uart often for REPL)
21         uartId, uartTx, uartRx = microcontroller.pin.uartPorts[0]
22         uart = busio.UART(uartTx, uartRx, baudrate=9600, timeout=3000)
23
24         gps = adafruit_gps.GPS(uart)
25
26         gps.send_command('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
27         gps.send_command('PMTK220,1000')
28
29         def try_fix():
30             gps.update()
31             return gps.has_fix
32
33         await_true("GPS fix", try_fix)
34
35         self.assertTrue(gps.satellites is not None)
36         self.assertTrue(-90 <= gps.latitude < 90)
37         self.assertTrue(-180 <= gps.longitude < 180)
38