Skip to content

commands send with send_command() might be ignored by the GPS #18

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

Closed
MSube opened this issue Apr 10, 2019 · 3 comments
Closed

commands send with send_command() might be ignored by the GPS #18

MSube opened this issue Apr 10, 2019 · 3 comments

Comments

@MSube
Copy link

MSube commented Apr 10, 2019

send_command() uses multiple write() operations to send the sentence and the GPS might not recognize the sentence if there is a delay in between the write operations.
Each send_command should produce one PMTK001 message and an absent message indicates that the command was not recieved.
The code below may or may not output 4 PMTK001 messages after a soft reboot on an Feather M4 Express with an attached GPS breakout.
Also, the GPS keeps sending the additional messages if the third PMTK314 is not received.

Combining the writes into a single one helps.

`
import board, busio, adafruit_gps
uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=3)
gps = adafruit_gps.GPS(uart, debug=True)

gps.update()
gps.send_command(b'PMTK314,-1')
gps.update()
gps.send_command(b'PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0')
gps.update()
gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0')
gps.update()
gps.send_command(b'PMTK220,1000')

for i in range(20):
gps.update()
`

@evaherrada
Copy link
Collaborator

Disregard my previous answers.

About the main issue you were having; gps.update needs to be called A BUNCH OF times before it actually returns anything. When I was testing your file, it ran over 4,700 times before it could actually return something. I'd try putting the gps.update in a while True loop and that will almost certainly fix that problem.

Now, about the second issue you were having with the GPS sending the additional packages. Not sure why that's happening, but from what I've gathered from the documentation about the GPS itself, it's almost certainly not on Circuitpython's end. Has something to do with the default settings on the GPS module itself. This can be solved by putting a time.sleep() in-between each PMTK314 packets being sent.

@evaherrada
Copy link
Collaborator

evaherrada commented May 15, 2019

Something like this might work better for what you want

import board, busio, adafruit_gps, time
uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=3)
gps = adafruit_gps.GPS(uart, debug=True)

gps.update()
gps.send_command(b'PMTK314,-1')
time.sleep(2)
while True:
    gps.update()
    if gps.update():
        break
gps.send_command(b'PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0')
time.sleep(2)
while True:
    gps.update()
    if gps.update():
        break
gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0')
time.sleep(2)
while True:
    gps.update()
    if gps.update():
        break
gps.send_command(b'PMTK220,1000')

i = 0
while i < 20:
    gps.update()
    if gps.update():
        i += 1

@evaherrada
Copy link
Collaborator

Addressed in #28. Closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants