I am looking for a way to parse a NMEA GPS message. Eadch message has 14 comma delimited fields. These fields may vary in length by one or two characters, for example, the latitude dcan be from 6 digits to 9 digits (ASCII). It would be nice if I could declare a structure and have the incoming string be split into each field as it is in Basics that support disk drives and also in C.
For Example:
dim GPSData as struct
dim msgDesig as string(6)
dim msgTime as string(6)
dim msgLat as string(9)
dim msgLon as string(9)
.
.
.
end struct
That when I receive a string via the serial port, it would automatically be loaded into this structure using the comma to delimit each field.
Is this anything that will do this automatically or do I have to break it out manually? If I do, is there a conditional "MID" function that works a little different than what I see in the manual. What would be good there is a function that looks like MID(<stringname>, <start character="">, <ending condition="">) where ending condition could be searching for a delimiter, i.e. ",".</ending></start></stringname>
Thanks,
Harley
N5BFB
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am looking for a way to parse a NMEA GPS message. Eadch message has 14 comma delimited fields. These fields may vary in length by one or two characters, for example, the latitude dcan be from 6 digits to 9 digits (ASCII). It would be nice if I could declare a structure and have the incoming string be split into each field as it is in Basics that support disk drives and also in C.
For Example:
dim GPSData as struct
dim msgDesig as string(6)
dim msgTime as string(6)
dim msgLat as string(9)
dim msgLon as string(9)
.
.
.
end struct
That when I receive a string via the serial port, it would automatically be loaded into this structure using the comma to delimit each field.
Is this anything that will do this automatically or do I have to break it out manually? If I do, is there a conditional "MID" function that works a little different than what I see in the manual. What would be good there is a function that looks like MID(<stringname>, <start character="">, <ending condition="">) where ending condition could be searching for a delimiter, i.e. ",".</ending></start></stringname>
Thanks,
Harley
N5BFB
Insight and an idea.
Insight. No structures - so, you need to use other methods.
Idea. I would use the ring buffer. Using the ring buffer look for start character and end character then loading into your variables.
Harley,
A few years back I did some gps work.
check out this thread
https://sourceforge.net/p/gcbasic/discussion/629990/thread/0e660522/