Show / Hide Table of Contents

Class SerialPortDevice

A Serial Port NMEA device

Inheritance
object
NmeaDevice
SerialPortDevice
Implements
IDisposable
Inherited Members
NmeaDevice.OpenAsync()
NmeaDevice.ReadAsync(byte[], int, int, CancellationToken)
NmeaDevice.CloseAsync()
NmeaDevice.MessageReceived
NmeaDevice.DeviceDisconnected
NmeaDevice.Dispose()
NmeaDevice.Dispose(bool)
NmeaDevice.IsOpen
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: NmeaParser
Assembly: NmeaParser.dll
Syntax
[Obsolete("Use WinRTSerialDevice type instead, as the underlying SerialPort implementation comes with a range of issues")]
public class SerialPortDevice : NmeaDevice, IDisposable
Remarks

Below is an example of connecting to a serial port using .NET Core or .NET Framework. Make sure you choose the correct port name and baud rate.

string portname = "COM3"; // Change to match the name of the port your device is connected to
int baudrate = 9600; // Change to the baud rate your device communicates at (usually specified in the manual)
var port = new System.IO.Ports.SerialPort(portname, baudrate);
var device = new NmeaParser.SerialPortDevice(port);
device.MessageReceived += OnNmeaMessageReceived;
device.OpenAsync();
...
private void OnNmeaMessageReceived(NmeaParser.NmeaDevice sender, NmeaParser.NmeaMessageReceivedEventArgs args)
{
   // called when a message is received
}

Constructors

Name Description
SerialPortDevice(SerialPort)

Initializes a new instance of the SerialPortDevice class.

Properties

Name Description
CanWrite

Gets a value indicating whether this device supports writing

Port

Gets the active serial port.

Methods

Name Description
CloseStreamAsync(Stream)

Closes the stream the NmeaDevice is working on top off.

OpenStreamAsync()

Creates and opens the stream the NmeaDevice is working on top off.

Write(byte[], int, int)

Writes data to the serial port (useful for RTCM/dGPS scenarios)

WriteAsync(byte[], int, int)

Writes to the device stream. Useful for transmitting RTCM corrections to the device Check the CanWrite property before calling this method.

Applies

TargetVersions
.NET Windowsmain, v3.0
.NET Frameworkmain, v3.0, v2.2, v2.1, v2.0
UWPmain, v3.0, v2.2, v2.1, v2.0
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX