get com port number of an USB adapter

后端 未结 5 941
既然无缘
既然无缘 2021-01-16 17:23

I am trying to write a program that uses an arduino mega and a FTDI-based USB to RS485 adapter.

I want to make the program user-friendly, thus I don\'t wont the user

5条回答
  •  遥遥无期
    2021-01-16 17:53

    as @Marcello Romani pointed out FTDI don't fall into the "serial port" category. Even though I am late I came across this problem recently and I fixed it using another query. Instead of searching in WIN32_SerialPort, you can query the Win32_PnPEntity class.One downside of using this class is that is slow to query.

     using (var searcher = new ManagementObjectSearcher
                ("SELECT * FROM Win32_PnPEntity"))
            {
                string[] portnames = SerialPort.GetPortNames();
                var ports = searcher.Get().Cast().ToList();
    
                foreach (ManagementBaseObject queryObj in ports)
                {
                }
    
            }
    

提交回复
热议问题