Serial port and GPS

IPClientGPS Class

Reads GPS data from the server

For a list of all members of this type, see IPClientGPS Members.

System.Object
   serial.IPClient
      serial.IPClientGPS

[Visual Basic]
Public Class IPClientGPS
    Inherits IPClient
[C#]
public class IPClientGPS : IPClient

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

This class is a replacement of the class SerialGPS, which uses IP (TCP, UDP, UDP broadcast) rather than the serial port for reading NMEA sequences. It supperts currently GGA sequences, from which it extracts the latitude, longitude, elevation and the UTC time, recomputes latitude and longitude into UTM using Utils.toUTM() and calls the callback method specified in the property CoordCb with the values extracted from the NMEA GGA sequence.

Example

Create a simple client test program connecting to the port 5000 of the server (here localhost) and printing the retrieved coordinates to the standard output. Use default system (Datum.WGS84) in order to convert geographical coordinates into UTM:

[C#]
using System;
using serial;

public class IPClientGPSTest {
  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() {
    IPClientGPS clnt;

    clnt = new IPClientGPS();
    clnt.CoordCb = new CoordDelegate(IPClientGPSTest.coordinates);
    clnt.oper(ServerType.TCP, "localhost", 5000);
  }
}
Compile the program to test.exe using either the Microsoft or mono compiler:
csc -out:test.exe IPClientGPSTest.cs IPClientGPS.cs IPClient.cs Utils.cs
gmcs -out:test.exe IPClientGPSTest.cs IPClientGPS.cs IPClient.cs Utils.cs
Obtain a source for valid NMEA GGA sequences. It could be of course a working GPS device, from which the data can be served using the application s2ip.exe. Alternatively use a file with recorded NMEA sequences, like the example file nmea.txt below:
$GPGGA,061245.000,4932.8663,N,01200.0203,E,1,04,2.2,424.3,M,47.4,M,,0000*5F
$GPGGA,061246.000,4932.8665,N,01200.0220,E,1,03,2.5,424.4,M,47.4,M,,0000*5C
$GPGGA,061247.000,4932.8667,N,01200.0240,E,1,04,2.2,424.5,M,47.4,M,,0000*58
$GPGGA,061248.000,4932.8668,N,01200.0262,E,1,04,2.2,424.9,M,47.4,M,,0000*54
$GPGGA,061249.000,4932.8670,N,01200.0275,E,1,04,2.2,425.0,M,47.4,M,,0000*52
$GPGGA,061250.000,4932.8673,N,01200.0282,E,1,04,2.2,424.6,M,47.4,M,,0000*56
$GPGGA,061251.000,4932.8676,N,01200.0287,E,1,04,2.2,424.5,M,47.4,M,,0000*54
$GPGGA,061252.000,4932.8680,N,01200.0288,E,1,04,2.2,424.4,M,47.4,M,,0000*50
$GPGGA,061253.000,4932.8683,N,01200.0293,E,1,04,2.2,424.8,M,47.4,M,,0000*54
$GPGGA,061254.000,4932.8682,N,01200.0293,E,1,03,4.1,424.4,M,47.4,M,,0000*5C
and create a TCP server for example using netcat listening for incoming connections on TCP port 5000 and serving slowly this file:
netcat -i 1 -l -p 5000 < nmea.txt
Finally start the compiled test program using test.exe or mono test.exe and wathc the coordinates coming from the network. See also the documentation on the class IPClient for alternative communication methods, like UDP or UDB broadcast.

Requirements

Namespace: serial

Assembly: sgps (in sgps.exe)

See Also

IPClientGPS Members | serial Namespace | Utils.toUTM() | IPClient | SerialGPS