Problem auto detecting Nano

I've been using the Uno and have used this routine for auto detecting the COM port:

This works fine for the Uno, but returns null for the Nano. When I looked under ports in device manager, the COM port is listed as 'USB Serial Port(COM12)', not 'Arduino Uno(COM3)'. Looking at the above code, it is searching for the string 'Arduino', which is why it fails for the Nano.

Does anyone else see this behavior also? Is there another way to detect the port a Nano is connected to?

Thanks

An Uno uses a 16U2 which tells the computer that it is an Uno.

The Nano uses a generic serial-to-usb ic for the communication which tells the computer that it is a generic com port.

Nothing that you can do about that, to my knowledge.

Is there another way to detect the port a Nano is connected to?

In addition of what sterretje wrote, you can modify the code mentioned in the stackexchange article to look for "USB Serial" instead of "Arduino". If you don't have another USB to serial adapter on that PC (other than the Nano) this should work too.

It sounds like there is not a generic way to detect which port a Nano is connected to. I believe the only method I can see to use is via serial communication. Poll each port for a certain return value. If you receive the value, then that port must have the Nano connected to it.

Since I already have two way communication with the sketch and my C# program on the laptop, this should not be too difficult to add.