Serial port and GPS

IPClientGPS Class

Reads GPS data from the server

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


[Visual Basic]
Public Class IPClientGPS
    Inherits IPClient
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.


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.


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:

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:
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.


Namespace: serial

Assembly: sgps (in sgps.exe)

See Also

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