2 parsing and data storage options, 1 splitstr, 2 converting strings to floating point numbers – Campbell Scientific GPS16-HVS Garmin GPS Receiver User Manual

Page 12: Parsing and data storage options, Splitstr, Converting strings to floating point numbers

Advertising
background image

Garmin 16-HVS GPS Receiver

4.2 Parsing and Data Storage Options

The CR1000, CR3000, CR800, and CR850 can store data as a string or as a

number. Every time the datalogger stores a string, the size of the string

determines the number of bytes used. If the string was declared to be 101 bytes

long, every time the string is written to memory, 101 bytes are used.

Depending on the application, the entire GPGGA string can be stored to

memory or just specific parts. When storing specific parts, some numbers can

be converted to floating data points.

To parse the GPGGA string, first read the entire string into 1 large string (see

Section 4.1). Next parse the string into a group of smaller strings (see Section

4.2.1). Determine which of the smaller strings to keep and which to convert to

floating point number, then store the data.

4.2.1 SplitStr

Use the SplitStr instruction to parse the GPGGA string into an array of strings.

Declare an array of 18 strings of 15 characters.
Example: ParseStr(18) as string * 15
The SplitStr instruction uses the result string, search string, filter string,

number of splits and split option to parse the search string and store the results

in the result string. The GPGGA string uses the comma character (chr(44))

between each parameter. The comma makes a nice marker to parse on.
Example: SplitStr (ParseStr(1),GPSData ,chr(44),18,5)

4.2.2 Converting Strings to Floating Point Numbers

Strings can be converted to floats with the simple assignment operator, but

Latitude and Longitude require more precision than the CR1000, CR3000,

CR800, or CR850 will store as a floating point number.

' Sample CR1000 program to read GPS NMEA GPGGA string
Public location, bytes
public GPSData as string * 101 ' $GPGGA string about 57 characters
PUBLIC ParseStr(18) as string * 15
' Aliases allow proper labels in output data tables,
' and when viewing public variables
alias ParseStr(1) = GPGGA
alias ParseStr(2) = TIME
alias ParseStr(3) = LAT
alias ParseStr(4) = HEMINS
alias ParseStr(5) = LONGI
alias ParseStr(6) = HEMIEW
alias ParseStr(7) = QUAL
alias ParseStr(8) = NUMSATS
alias ParseStr(9) = HDP
alias ParseStr(10) = ALTDE
alias ParseStr(11) = ALTUNIT
alias ParseStr(12) = GIODAL
alias ParseStr(13) = GEOUNIT
alias ParseStr(14) = AGE
alias ParseStr(15) = DIFFREF
alias ParseStr(16) = ASTERISK
alias ParseStr(17) = CHCKSUM
alias ParseStr(18) = CRLF

6

Advertising