Method FromSerialPort
FromSerialPort(DeviceInformation, Nullable<UInt32>)
Creates a NMEA LocationDataSource based on a serial port.
Declaration
public static NmeaLocationDataSource FromSerialPort(DeviceInformation deviceInformation, uint? baudRate)
Parameters
Type | Name | Description |
---|---|---|
DeviceInformation | deviceInformation | The Serial port device info. |
Nullable<System.UInt32> | baudRate | The baud rate of the device being connected to. |
Returns
Type | Description |
---|---|
NmeaLocationDataSource | A NMEA Location Datasource that reads from the specified serial port |
Remarks
The created datasource will automatically handle creating and opening the specified serial port when the datasource is started. Once the datasource has been started, the NmeaDataStream will be available.
To use 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>
To obtain a serial port device id, you can use the Device Selector API to search for it:
var deviceInfo = (await DeviceInformation.FindAllAsync(SerialDevice.GetDeviceSelector()))?.FirstOrDefault(); // Gets the first serial port
Applies to
Platforms and versions
Target | Versions |
---|---|
.NET 6.0 Windows | 100.15 |