GPS16-HVS GPS Receiver
Example: Public GPSdata as string * 101
Example: SerialIn (GPSData,com1,20,13,100)
4.1.3 SerialFlush
The SerialFlush instruction is used to clear all data from the buffer associated
with the serial port.
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
7