Hi, I use arduino uno board with my C# program. After I unplug arduino USB cable while program works and reads data from arduino, and plug it back in my program can't find port. It gives me message that COMx port does not exist. I have to close program, unplug arduino again, plug it back in and run program again to work. Is there any way to fix this problem?
So - don't unplug the USB cable?
Although this is an old request the issue is still real.
My reply is due to the answer 'So - don't unplug the USB cable?'
One might expect that a device once uplugged can be reinserted and works again without to restart application or even computer.
Where you can unplug and reconnect an Arduino with a FTDI chip as for example the Duemilanove it just works. If you do the samewith the Arduino's using AtMega16U2 chips for UART as the Uno does it fails.
In MS-windows-system-devices-manager overview a re inserted 'Arduino Uno' is seen as device 'Aduino Uno' but if one renew the list of all available Comports the previous com port is missing in the list.
If you use Windows ManagementObject to retrieve all Arduino devices it is in the list and even with the old previous used comport number.
But once you try to re establish a connection with this port again one gets an exception 'ComX Does not exists'
In my humble opinion one might call this a bug if there is no easy solution to reestablish connection again
Most of this problem was fixed by upgrading the IDE. In the earlier IDE, when a device was unplugged, the IDE removed it from its list which was not refreshed in the positive sense until the IDE was actually restarted.
The later IDE versions dynamically determine the list of COM ports, so the same port is again available when you use the Tools => Port option to select it. But unplugging it has closed the "handle" that was previously in use.
Linux (Mint) has a different behaviour also.