Exemple #1
0
        public static async Task <IGpsManager> Create(GpsManagerSettings settings)
        {
            string deviceSelector = SerialDevice.GetDeviceSelector(settings.PortName);
            DeviceInformationCollection deviceInformationCollection = await DeviceInformation.FindAllAsync(deviceSelector);

            SerialDevice serialDevice = await SerialDevice.FromIdAsync(deviceInformationCollection[0].Id);

            if (serialDevice == null)
            {
                throw new Exception(
                          "Serial port not opened. Is the DeviceCapability activated in the Package.appxmanifest file of the project?\r\n" +
                          "   <Capabilities>\r\n" +
                          "     <DeviceCapability Name=\"serialcommunication\">\r\n" +
                          "       <Device Id=\"any\" >\r\n" +
                          "         <Function Type=\"name:serialPort\" />\r\n" +
                          "       </Device>\r\n" +
                          "     </DeviceCapability>\r\n" +
                          "   </Capabilities>");
            }

            return(new GpsManager(serialDevice));
        }
Exemple #2
0
 /// <summary>
 /// Create an instance of <see cref="IGpsManager"/>.
 /// </summary>
 /// <param name="settings">The settings of <see cref="IGpsManager"/>.</param>
 /// <returns></returns>
 public static Task <IGpsManager> Create(GpsManagerSettings settings)
 {
     return(GpsManager.Create(settings));
 }