4

I am trying to test code for simple comms with a serial device (at the moment just a hard loopback). The USB to serial adapter I'm using installs on COM20 by default, but disconnecting and reconnecting a few times has caused it to bind to COM21.

I would like to try and make my life a little easier and search for the port that is bound to the USB-serial driver. On TeraTerm, I get to choose from a dropdown that shows all COM ports and drivers. I would like to add that functionality to my code.

The SerialPort class only has a GetPortNames method that simply gives all the port names, i.e. COM1, COM2, ..., COM21 etc.

ProfK
  • 49,207
  • 121
  • 399
  • 775

1 Answers1

0

Please have a look at my answer here: How to open a serial port by friendly name?

It is not exactly what you ask for, but should satisfy your demands as is, and can also be modified to do exactly what you want.

Community
  • 1
  • 1
Pavel Radzivilovsky
  • 18,794
  • 5
  • 57
  • 67