DKW.NMEA 1.2.137

Reads a stream of NMEA sentences parsing it into NMEA objects

There is a newer version of this package available.
See the version list below for details.
Install-Package DKW.NMEA -Version 1.2.137
dotnet add package DKW.NMEA --version 1.2.137
<PackageReference Include="DKW.NMEA" Version="1.2.137" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DKW.NMEA --version 1.2.137
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

DKW NMEA

Build status

A very fast NMEA parser. The speed is achieved by
using System.Buffers, System.IO.Pipelines, Span&lt;T&gt; and related bits and pieces
avoiding as many allocations as possible.

(This is my first foray into Buffers and Pipelines... Be Gentle!)

Usage

Synchronous:

using (var nr = new NmeaReader(File.Open("track2.nmea")))
{
  while (true)
  {
    var message = nr.ReadNext();
    if (message == null)
    {
      break;
    }
    Console.WriteLine(message);
  }
}

Asynchronous:

using (var nr = new NmeaReader(File.Open("track2.nmea")))
{
  while (true)
  {
    var message = await nr.ReadNextAsync().ConfigureAwait(false);
    if (message == null)
    {
      break;
    }
    Console.WriteLine(message);
  }
}

Bloody freaking crazy Asynchronous:

var nsr = NmeaStreamReader.Create();
using (var reader = File.Open("track1.nmea"))
{
  await nsr.ParseStreamAsync(reader, (s) =>
  {
    Console.WriteLine(message);
  }).ConfigureAwait(false);
}

Filtering

If you are only interested in a specific NMEA sentence then build the NmeaStreamReader yourself:

var nsr = new NmeaStreamReader().Register(new GGA());

Parsers are available for:

  • GPGGA
  • GPGLL
  • GPGSA
  • GPGSV
  • GPRMC

But don't despair! It's easy to add new sentences.

public class GLL : NmeaMessage
{
  private static readonly ReadOnlyMemory<Byte> KEY = Encoding.UTF8.GetBytes("$GPGLL").AsMemory();
  protected override ReadOnlyMemory<Byte> Key => KEY;

  public Double Latitude { get; private set; }
  public Double Longitude { get; private set; }
  public TimeSpan FixTime { get; private set; }
  public Char DataActive { get; private set; }

  public override String ToString() => $"GPGLL {Latitude} {Longitude} {FixTime} {DataActive}";

  public override NmeaMessage Parse(ReadOnlySequence<Byte> sentence)
  {
    var lexer = new Lexer(sentence);

    if (lexer.NextString() != "GPGLL")
    {
      throw lexer.Error();
    }

    return new GLL()
    {
      Latitude = lexer.NextLatitude(),
      Longitude = lexer.NextLongitude(),
      FixTime = lexer.NextTimeSpan(),
      DataActive = lexer.NextChar(),
      Checksum = lexer.NextChecksum()
    };
  }
}

DKW NMEA

Build status

A very fast NMEA parser. The speed is achieved by
using System.Buffers, System.IO.Pipelines, Span&lt;T&gt; and related bits and pieces
avoiding as many allocations as possible.

(This is my first foray into Buffers and Pipelines... Be Gentle!)

Usage

Synchronous:

using (var nr = new NmeaReader(File.Open("track2.nmea")))
{
  while (true)
  {
    var message = nr.ReadNext();
    if (message == null)
    {
      break;
    }
    Console.WriteLine(message);
  }
}

Asynchronous:

using (var nr = new NmeaReader(File.Open("track2.nmea")))
{
  while (true)
  {
    var message = await nr.ReadNextAsync().ConfigureAwait(false);
    if (message == null)
    {
      break;
    }
    Console.WriteLine(message);
  }
}

Bloody freaking crazy Asynchronous:

var nsr = NmeaStreamReader.Create();
using (var reader = File.Open("track1.nmea"))
{
  await nsr.ParseStreamAsync(reader, (s) =>
  {
    Console.WriteLine(message);
  }).ConfigureAwait(false);
}

Filtering

If you are only interested in a specific NMEA sentence then build the NmeaStreamReader yourself:

var nsr = new NmeaStreamReader().Register(new GGA());

Parsers are available for:

  • GPGGA
  • GPGLL
  • GPGSA
  • GPGSV
  • GPRMC

But don't despair! It's easy to add new sentences.

public class GLL : NmeaMessage
{
  private static readonly ReadOnlyMemory<Byte> KEY = Encoding.UTF8.GetBytes("$GPGLL").AsMemory();
  protected override ReadOnlyMemory<Byte> Key => KEY;

  public Double Latitude { get; private set; }
  public Double Longitude { get; private set; }
  public TimeSpan FixTime { get; private set; }
  public Char DataActive { get; private set; }

  public override String ToString() => $"GPGLL {Latitude} {Longitude} {FixTime} {DataActive}";

  public override NmeaMessage Parse(ReadOnlySequence<Byte> sentence)
  {
    var lexer = new Lexer(sentence);

    if (lexer.NextString() != "GPGLL")
    {
      throw lexer.Error();
    }

    return new GLL()
    {
      Latitude = lexer.NextLatitude(),
      Longitude = lexer.NextLongitude(),
      FixTime = lexer.NextTimeSpan(),
      DataActive = lexer.NextChar(),
      Checksum = lexer.NextChecksum()
    };
  }
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.155 337 4/25/2019
1.2.154 174 4/25/2019
1.2.153 167 4/25/2019
1.2.151 173 4/25/2019
1.2.150 178 4/25/2019
1.2.144 170 3/30/2019
1.2.142 167 3/9/2019
1.2.141 186 1/22/2019
1.2.140 165 1/22/2019
1.2.138 170 12/19/2018
1.2.137 175 12/19/2018
1.2.135 156 12/19/2018
1.2.134 168 12/12/2018
1.2.133 181 12/12/2018
1.1.0 219 12/7/2018
1.1.0-beta0001 201 12/5/2018
1.1.0-alpha0001 265 12/7/2018
1.0.2 190 12/5/2018
1.0.1 184 12/4/2018
0.1.0-alpha0008 166 12/1/2018
Show less