Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to compare the string and Extract the particular sentence

Status
Not open for further replies.

Mani Yuvan

Member level 1
Joined
Jan 18, 2015
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Location
Tamilnadu , India
Activity points
321
I want extract from the $GPGGA sentence to show the latitude and longitude value. I did nested if statement and show the value in lcd.But it not too fair.
If any one can teach me how to store all data from GPS and among them extract particular $GPGGA sentence and shows the latitude longitude value using string comparison method.
Im good at only C18 compiler.
 

hi,
I use Oshonsoft Basic.
Dim an Array(72) Bytes
On UART input jump to an interrupt subroutine.
Test the Character in the RXD buffer for '$', if a "$" sign then fill Array until CRLF characters [ 0Dh, 0Ah] at end of GPGGA message.

This will give you an array that contains all the GPS message.

To Parse the Lat and Long values, count the ',' [ comma ] character value separator in the message Array buffer.
This will give you the value Start/End position in the Array buffer, test for zero to dump invalid GPS data.

E
 

Or in 'C' use 'strstr( , )' which returns the position of one string in another or NUL if the string is not present.

Brian.
 

Alternatively, you could try using a tokenization ...
I think my first question would be what kind of MCU are you using. Does it have a Tx or Rx buffers built into the UART peripheral? I am going to assume it does.
You could have you code reference the buffer location and copy it to a (processor) local string so the processor has a copy in its memory.
With tokenization, you can chose the character(s) that denote the beginning of a specified field in the buffer (string).
This strategy allows should allow the UART to continue its operation while the MCU processes the local buffer.

- Josh
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top