Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 09:53 05 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Reading from UART too fast ? GPS checksum

Author Message
vk4tec

Senior Member

Joined: 24/03/2012
Location: Australia
Posts: 239
Posted: 02:18am 29 Dec 2012
Copy link to clipboard 
Print this post

Hello

When I was coding in Assembly and PIC's I know it was a good practice to not blindly rush into the receive section of th USART but observe a few rules.

For instance check the presence of a character and also don't let the recieve buffer get over run.

I am seeing something like this in MMBASIC

If I try and read two characters really quickly, from a GPS the second of the two characters is sometimes not populated.

If if put a "pause 10" in there, it works 100%

get_nmea ( this return $.........................* )

$GPRMC,122030.2,A,2720.25427,S,15302.59721,E,000.00,167.7,29 1212,011.0,E*

Then I use a statment to get two more characters to "tack" on the end. "45"

$GPRMC,122030.2,A,2720.25427,S,15302.59721,E,000.00,167.7,29 1212,011.0,E*45

Maybe I can use CR or LF instead as the trigger ???

It as if I am reading from the USART too quickly.

What it is is the checksum from a NMEA GPS stream.

The parsing code takes in all characters from $.............*XY

$GPRMC,122030.2,A,2720.25427,S,15302.59721,E,000.00,167.7,29 1212,011.0,E*

The code forms msg$ from "$" to "*" and misses XY the checksum.

Some programs want the check sum.

So I just read two characters and append on the end of MSG$

45

I have to slow it down and put a pause 10 in between reading X and Y

Otherwise I get "$.............................*X < and no Y >

Curious

- Andrew -


Edited by vk4tec 2012-12-30
Andrew Rich VK4TEC
www.tech-software.net
 
rhamer
Senior Member

Joined: 06/06/2011
Location: Australia
Posts: 174
Posted: 03:37am 29 Dec 2012
Copy link to clipboard 
Print this post

That data seems to be fixed length, so you need to sit in a while loop until you have received all characters.

Something like;

Do while char count < xx
Read char
Increment char count
Loop

Not the right syntax, and it assumed the read char is blocking, but you get the idea.

Cheers

Rohan
Rohan Hamer
HAMFIELD Software & Hardware Solutions

Makers of the Maximite Expander.

http://www.hamfield.com.au
 
cwilt
Senior Member

Joined: 20/03/2012
Location: United States
Posts: 147
Posted: 10:10am 29 Dec 2012
Copy link to clipboard 
Print this post

Andrew,

The way I did it was to parse the fields and not the whole sentence. Each field ends with a comma and checksum ends with CRLF. As the fields were parsed I would fill variables. When the variables were full then display, save to file, or both. This allowed the buffer time to fill while parsing each field.

Maybe not the best way but it allowed me to write 1 NEMA handling routine for all nema strings that way if I change gps units that may have different outputs it still works.
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 12:40pm 29 Dec 2012
Copy link to clipboard 
Print this post

Instead of an arbitrary pause you could use:

DO WHILE LOC(#1) < 2 : LOOP

Geoff Graham - http://geoffg.net
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024