Class SerialPortDevice
A Serial Port NMEA device
Implements
Inherited Members
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
Target | Versions |
---|---|
.NET Windows | GitHub, v3.0 |
.NET Framework | GitHub, v3.0, v2.2, v2.1, v2.0 |
UWP | GitHub, v3.0, v2.2, v2.1, v2.0 |