StartGPS()
Summary
Initializes reading from a GPS device.
Syntax
StartGPS(string device, array options)
| Argument | Contents |
|---|---|
| device | Either "File" or "Serial Port" |
| Option | Type | Contents |
|---|---|---|
| Read From | String | The file name (when device is "File") or the name of the serial port to read from ( e.g., \\.\com1 to read from the COM1 serial port); a required option |
| Time Interval | Integer | For File devices: The time span between records provided by subsequent calls to GetGPSInfo(). E.g., a Time Interval of 4 means that for two subsequent calls to GetGPSInfo(), the second will be based on readings that are time-stamped up to four seconds after the first one |
The following options apply to serial ports only:
| Option | Type | Contents |
|---|---|---|
| Baud Rate | Integer | The data baud rate, in bytes per second |
| Parity | String | "None", "Odd", "Even", or "Space" |
| Data Bits | Integer | The number of data bits: 5, 6, 7, or 8 |
| Stop Bits | Real | 1, 1.5, or 2 |
| Log File | String | The name of a file to save an exact copy of the input, as it is read; if omitted, no logging will take place |
Notes
-
All data from the input file or the serial port are assumed to be in the NMEA 0183 format.
-
The appropriate specification of Baud Rate, Parity, Data Bits and Stop Bits depends on the GPS receiver being used. Refer to the user's manual for your GPS equipment.
Example
options = {{"Read From", "\\\\.\\COM1"}, {"Baud Rate", 4800}, {"Data Bits", 8},
{"Stop Bits", 1}, {"Parity", "None"}} // Most common settings
StartGPS("Serial Port", options)
dim pos[10]
for i=1 to 10 do
gps_data = GetGPSInfo()
if gps_data.length = 1 then
ShowMessage("An error while reading: " + gps_data[1])
else if gps_data[1] <> null && gps_data[2] <> null then
// Store the location as a coordinate
pos[i][ = Coord(gps_data[1], gps_data[2])
end // for
StopGPS()
Error Codes
| Error Type | Meaning |
|---|---|
| Error | An invalid device or option was specified; the file/port was already open or wasn't found; the log file already exists or couldn't be created; or the serial port is in use |
See Also
| Function | Summary |
|---|---|
| GetGPSInfo() | Obtains a reading from a GPS device |
| StopGPS() | Closes a GPS device |