Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force a COM port to close

I'm working on an application that uses COM port for communication with external controller. When I reboot the PC with communication cable connected, Windows (7) opens the port, without any application running, so I can't access it any more. I tried to close it programatically, but it just stays taken.

Anyone got an idea how can I force it to close, any program I can run before my app, or a way to programatically close it no matter what?

like image 658
Clone Avatar asked Aug 26 '11 16:08

Clone


1 Answers

I didn't manage to close the port, but after a lot of searching and testing I found what was the source of my problems. I'm posting the solution to help anyone who has the same problem.

Windows identifies devices with constant data stream connected to serial port as serial mouse (in this system it was Microsoft Serial Ballpoint), and tries to install them, taking over the control over the port without any process using it. The solution is to wait for Windows to install the device (check Device Manager under Mouses And Other Pointing Devices) and then DISABLING it. If you uninstall the device it will be installed again, and the problem is back.

Thanks to everyone who tried to help, and I hope others will find this solution useful.

like image 152
Clone Avatar answered Sep 17 '22 16:09

Clone