I have written a program in C# that allows me to communicate (using AT Commands) with the serial ports inside of our computers. The code to find the ports looks like this:
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_PnPEntity");
//This loops through the results from the searcher
foreach (ManagementObject queryObj in searcher.Get())
{
//If it finds the port,
if (queryObj["Caption"].ToString().Contains("##### Wireless AT"))
{
//it writes it to the file
sw.WriteLine("serial port : {0}", queryObj["Caption"] + "\n");
sw.Flush();
}
This code works splendidly with our older modems, it searches through the COM ports and finds the AT Wireless Command port. This is the port which I eventually send my AT commands to. Here are two pictures of the device manager of the ports I am searching for
The issue is, we are rolling out our computers with newer modems, and these work differently...
The new modems do not use serial ports with physical listing of ports in the device manager. Also, the serial port does not show up in the Win32_PnpEntity
search... The serial port is listed under the modem properties.
My question is, how do I find the serial port of the modem using C#?
Please let me know if there is some way I can elaborate.
-Luke