Show / Hide Table of Contents

Class WinRTSerialDevice

A Serial Port NMEA device using Windows' WinRT APIs.

Inheritance
object
NmeaDevice
WinRTSerialDevice
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
public class WinRTSerialDevice : NmeaDevice, IDisposable
Remarks

To use the NMEA Parser against a serial device in a Windows 10 Universal app, ensure the serial device capability is enabled by opening package.appxmanifest in a text editor, and add the following to the <Capabilities> section:

<DeviceCapability Name="serialcommunication"> 
  <Device Id="any">
    <Function Type="name:serialPort" /> 
  </Device> 
</DeviceCapability>
var selector = SerialDevice.GetDeviceSelector("COM3"); //Get the serial port on port '3'
var devices = await DeviceInformation.FindAllAsync(selector);
if(devices.Any()) //if the device is found
{
	var deviceInfo = devices.First();
    var serialDevice = await SerialDevice.FromIdAsync(deviceInfo.Id);
    //Set up serial device according to device specifications:
    //This might differ from device to device
    serialDevice.BaudRate = 4800;
	serialDevice.DataBits = 8;
	serialDevice.Parity = SerialParity.None;
	var device = new NmeaParser.SerialPortDevice(serialDevice);
    device.MessageReceived += device_NmeaMessageReceived;
}
...
private void device_NmeaMessageReceived(NmeaParser.NmeaDevice sender, NmeaMessageReceivedEventArgs args)
{
    // called when a message is received
}

Constructors

Name Description
WinRTSerialDevice(SerialDevice)

Initializes a new instance of the SerialPortDevice class.

Properties

Name Description
CanWrite

Gets a value indicating whether this device supports writing

SerialDevice

Gets the active serial port.

Methods

Name Description
CloseStreamAsync(Stream)

Closes the stream the NmeaDevice is working on top off.

GetSerialDevicesAsync()

Gets a list of serial devices available.

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
UWPmain
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX