Garmin GPS 16HVS Instruction Manual - Page 10

Parsing and Data Storage Options

Page 10 highlights

Garmin 16-HVS GPS Receiver 4.1.4 SerialClose The SerialClose instruction is used to close the serial port. Once closed, the SerialOpen command must be used before more data can be read. 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 6

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

Garmin 16-HVS GPS Receiver
4.1.4
SerialClose
The SerialClose instruction is used to close the serial port.
Once closed, the
SerialOpen command must be used before more data can be read.
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
6