NMEA (GPS) parsing of a string and serial question
arno
Posts: 43
Hello,
i try to use a basic stamp to interface a GPS with a GSM modem, but I have 2 problems:
1: how can parse the string I get from my GPS, the lenght is not define, but I have a comma as separator ?
in C it something like strcat
2: Is their a way to know how much data I got from the SERIN function ?
thanks for any help.
regards
arno
i try to use a basic stamp to interface a GPS with a GSM modem, but I have 2 problems:
1: how can parse the string I get from my GPS, the lenght is not define, but I have a comma as separator ?
in C it something like strcat
2: Is their a way to know how much data I got from the SERIN function ?
thanks for any help.
regards
arno
Comments
What kind of stamp do you have?· The BS2P is best suited (with its additional scratchpad ram) for storing GPS strings, but there are other ways to hammer it through.
I'm attached a program by Jon Williams (sorry if I'm stepping on your toes Jon) where he uses a BS2 and the WAIT modifier in a SERIN command to get the data of a defined string.
What string are you trying to bring in?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
Thanks for the code, I'm using a bs2p, and the problem with the code you give me is that the NMEA data are not allways full, sometime GPS receiver didn't give data in one or 2 field, but they have to put comma on it to make the separation. The code of Jon is nice, but it's not NMEA.
For know I'm testing my code with $GPRMC, but i will ned 2 other more $GP code, so I realy need a way to parse the code for the coma. If I can know how mutch data I get from my SERIN function I can do a FOR loop and test every char until I reach the comma, but I can't get that information.
Eventually I can a loop with DO WHILE and put my string in a temp array before working with it.
But thanks for the sample of code.
If the character length is fixed after the comma, you can read the serial into a string array, but using string arrays will eat up your variable space quick from my experience with the BS2...so you might want to store it as decimal.
Post Edited (ktekx) : 3/2/2006 8:54:16 PM GMT
EX 1:
( getting lat/lon from $GPGGA. WordData1 and 2 - lat and lon, ByteData1 and 2 - N/S E/W)
GetLatLong:
SERIN RxD,Baud48, [noparse][[/noparse]WAIT("GPGGA,"),SKIP 9,DEC WordData1, ' Read the GGA sentence from LassenIQ GPS
SKIP 6, ByteData1, DEC WordData2,SKIP 6, ByteData2,
SKIP 2,DEC NibData]
SEROUT TxD, Baud48, [noparse][[/noparse]CRSRXY, 7, 10, DEC WordData1 DIG 3, DEC WordData1 DIG 2,DegSym, " ", ' Then display it
DEC WordData1 DIG 1, DEC WordData1 DIG 0,MinSym, " ", ByteData1,CLREOL,
CRSRXY, 7,11,DEC WordData2 DIG 4, DEC WordData2 DIG 3, DEC WordData2 DIG 2,DegSym, " ",
DEC WordData2 DIG 1, DEC WordData2 DIG 0,MinSym, " ", ByteData2,CLREOL,CRSRXY,20,9,
DEC NibData, CLREOL]
RETURN
EX 2:
(Getting speed from $GPVTG )
GetSpeed:
SERIN RxD, Baud48, [noparse][[/noparse]WAIT("VTG,"), WAIT(","), ' Read the VTG sentence from GPS -
WAIT(","),WAIT(","),DEC WordData1]
SEROUT Txd,Baud48, [noparse][[/noparse]CRSRXY, 7, 12, DEC WordData1,CLREOL ' Then display it
RETURN
Thanks...
Jamie
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--
Jamie C. Pole
Principal Consultant
J.C. Pole & Associates, Inc.
http://www.jcpa.com/