question

AnishV-0241 avatar image
0 Votes"
AnishV-0241 asked DanielZhang-MSFT edited

Serial port detection takes more time than usual while having the serial over bluetooth port enabled under device manager.

Serial port detection libraries are taking more time than usual while having the serial over Bluetooth port enabled under device manager ports section. I'm using ManagementObjectSearcher for detecting the com ports in our C# code.

dotnet-csharp
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @AnishV-0241,
It may be related to the virtual port.
You can try to check the hidden serial ports in Device Manage via following steps:
1.Run Device Manager from elevated command line:

 > set DEVMGR_SHOW_NONPRESENT_DEVICES=1
 > devmgmt.msc

2.Enable "Show hidden devices" in the menu, and uninstall grayed-out COM ports.
>>I'm using ManagementObjectSearcher for detecting the com ports in our C# code.
Could you please more related code to find the problem?
Best Regards,
Daniel Zhang


0 Votes 0 ·

Please find the below code snippet from my code:

ManagementObjectSearcher comPortSearcher = new ManagementObjectSearcher(@"root\cimv2", @"SELECT * FROM Win32_SerialPort");
List<string> portNames = new List<string>();
ObservableCollection<string> comPorts = new ObservableCollection<string>();
try
{
using (comPortSearcher)
{
string caption = null;
foreach (ManagementObject obj in comPortSearcher.Get())
{
if (obj != null)
{
object captionObj = obj["Caption"];
if (captionObj != null)
{
caption = captionObj.ToString();
if (caption.Contains("(COM"))
{
portNames.Add(caption);
}
}
}
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}

0 Votes 0 ·

0 Answers