-
Notifications
You must be signed in to change notification settings - Fork 60
Update adafruit_gps.py #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update adafruit_gps.py #17
Conversation
This is WAY faster. I was able to get the example file to run once every 0.01 seconds (I didn't try any faster than that) and without the code you suggested, it ran at a maximum of once every 0.08 seconds. |
The only thing I'm wondering about is the GPS chip having a max refresh rate of 10Hz. Anything faster than that could produce duplicate data. |
_uart.readline() blocks because it waits for the \r that terminates the NMEA sentence. A better approach is to use read(nbytes=in_waiting) if in_waiting > 0 and collect the incoming bytes in your own buffer. This way you only need to check every 64 ms to avoid an UART overflow. |
By read() are you referring to self._uart.read() or something else? |
yes, _uart.read() |
Feel free to look at MSube/CircuitPython_GPS_NMEA, the update() function in msube_gps.py is doing this. |
ok cool - yeah we didnt have |
Updating https://github.com/adafruit/Adafruit_CircuitPython_CCS811 to 1.1.5 from 1.1.4: > Merge pull request adafruit/Adafruit_CircuitPython_CCS811#29 from mitchellhenke/patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_Crickit to 2.1.5 from 2.1.4: > Merge pull request adafruit/Adafruit_CircuitPython_Crickit#16 from caternuson/example_update Updating https://github.com/adafruit/Adafruit_CircuitPython_GPS to 3.2.4 from 3.2.3: > Merge pull request adafruit/Adafruit_CircuitPython_GPS#17 from jomogalla/checking-input-buffer-before-reading > Merge pull request adafruit/Adafruit_CircuitPython_GPS#24 from dherrada/docs > Merge pull request adafruit/Adafruit_CircuitPython_GPS#21 from dherrada/master > Merge pull request adafruit/Adafruit_CircuitPython_GPS#23 from dherrada/docs Updating https://github.com/adafruit/Adafruit_CircuitPython_INA219 to 3.2.0 from 3.1.2: > Merge pull request adafruit/Adafruit_CircuitPython_INA219#9 from barbudor/master Updating https://github.com/adafruit/Adafruit_CircuitPython_LPS35HW to 1.1.0 from 1.0.0: > added low pressure threshold Updating https://github.com/adafruit/Adafruit_CircuitPython_Seesaw to 1.4.1 from 1.4.0: > Merge pull request adafruit/Adafruit_CircuitPython_seesaw#28 from makermelissa/master > Merge pull request adafruit/Adafruit_CircuitPython_seesaw#29 from robotics-masters/wallarug/robohatmm1 Updating https://github.com/adafruit/Adafruit_CircuitPython_SGP30 to 2.0.2 from 2.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_SGP30#15 from djmbritt/patch-1
Changed code from PR #17 from 64 bytes to 32 bytes
I was trying to call update() in the adafruit_gps.py module and it would take quite a while, blocking my program from continuing until
_uart.readline()
returned.By adding a check to make sure the number of bytes in the input buffer was at least 64, the module doesn't seem to block while waiting for bytes in the buffer.