SerialDevice.FromIdAsync (string identifier) ​​timeout

Here is a fragment of the UWP application that I am writing

// [...] using Windows.Devices.Enumeration; using Windows.Devices.SerialCommunication; using Windows.Networking.Connectivity; // [...] private Dictionary<string, SerialDevice> _SerialDevices = new Dictionary<string, SerialDevice>(); // [...] var serialSelector = SerialDevice.GetDeviceSelector(); var serialDevices = (await DeviceInformation.FindAllAsync(serialSelector)).ToList(); var hostNames = NetworkInformation.GetHostNames().Select(hostName => hostName.DisplayName.ToUpper()).ToList(); // So we can ignore inbuilt ports foreach (var deviceInfo in serialDevices) { if (hostNames.FirstOrDefault(hostName => hostName.StartsWith(deviceInfo.Name.ToUpper())) == null) { try { var serialDevice = await SerialDevice.FromIdAsync(deviceInfo.Id); if (serialDevice != null) { _SerialDevices.Add(deviceInfo.Id, serialDevice); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } } 

I added to the Package.appxmanifest file for the project

following:
 <DeviceCapability Name="serialcommunication"> <Device Id="any"> <Function Type="name:serialPort" /> </Device> </DeviceCapability> 

When I get to the line var serialDevice = await SerialDevice.FromIdAsync(deviceInfo.Id); , it throws an exception:

{System.Exception: semaphore timeout period has expired. (Exception from HRESULT: 0x80070079)
in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task)
in System.Runtime.CompilerServices.TaskAwaiter`1.GetResult ()
in TorinoBluetooth.UwpHidConnector.d__9.MoveNext ()}

Why is this failing? Is there anything in UWP that prevents serial connections this way?

(NB I know that the serial connection is OK, as I can find it in the Device Manager, where it is listed as “Standard Bluetooth Serial Communication (COM8)”, and then connect the other code manually to “COM8”.)

0
bluetooth uwp serial-port
source share

No one has answered this question yet.

See similar questions:

31
Semaphore timeout error for USB connection
7
Obtaining a COM port name for a known Bluetooth device in UWP

or similar:

one
POST request failed due to invalid or incorrect certificate
one
Connect to an EPSON ePOS t88V Printer from .NET UWP
one
UWP socket client exception when trying to connect: ThrowForNonSuccess (Task task)
0
Error DEP0700: Failed to register application. [0x80073D01] error 0x800704EC: Package Deployment ... was blocked by AppLocker
0
ZXing.Net UWP camera freezes
0
UWP serial synchronization device
0
Uwp application cannot connect to Wcf service using net.tcp
0
How to get a file from a file path

All Articles