Reads coordinates from a GPS serial port
For a list of all members of this type, see SerialGPS Members.
System.Object
serial.Serial
serial.SerialGPS
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
Reads serial port using the method parseNMEA(), which is passed to the porperty RdLineCb to the base class. Each line successfully read from the serial port is parsed using Utils.fromGGA() and for the coordinates, if any, the delegate set by CoordDelegate is called. Only NMEA GGA sequences currently supported.
The following example reads GPS coordinates from COM4, 9600, 8N1, WGS84 is used for converting geographical coordinates into UTM. The coordinates are the printed to standard output.
[C#]
using System;
using serial;
public class SerialGPSTest {
private static void coordinates(double tim,
double latitude,
double longitude,
double utmnorth,
double utmeast,
double altitude) {
Console.WriteLine("{0} {1} {2} {3} {4} {5}",
tim, latitude, longitude,
utmnorth, utmeast, altitude);
}
public static void Main() {
SerialGPS s;
s = new SerialGPS();
s.CoordCb = new CoordDelegate(SerialGPSTest.coordinates);
s.Open("COM4", 9600, 8, Parity.None, StopBits.One, Datum.WGS84);
Console.WriteLine("Hit ENTER to close"); Console.ReadLine();
s.Close();
}
}
The code can be compiled using: csc -out:test.exe SerialGPSTest.cs SeriaGPS.cs Serial.cs Utils.cs gmcs -out:test.exe SerialGPSTest.cs SeriaGPS.cs Serial.cs Utils.cs
Namespace: serial
Assembly: sgps (in sgps.exe)
SerialGPS Members | serial Namespace | Utils.fromGGA() | Utils.toUTM()