views:

1149

answers:

1

I'm working on an App that talks to a serial port, and on my development machine, I'm running Vista, and that serial port is a Bluetooth connection. Occasionally, the serial port gets caught in a state where my App can no longer connect to it. In .net I get an IOException with a message reading "Element not found."

I've tried restarting the App, connecting with other Apps (a communications client like HyperTerm) but nothing helps. I can't find any more specific error message, and nothing is logged to the machine's event logs. The device manager tells me the port is "working properly."

Is there any way to find out which process and or .dll has possession of a serial port, and/or force a port closed?

If it makes any difference, my App is in C#, but structurally, it's not convenient to open and close the port with a "using" statement.

Thanks, Andy

+1  A: 

To the best of my knowledge you can't close a serial port that you do not have the handle to. My experience of Bluetooth serial ports is that they can end up getting mapped to different COM port numbers at connection time, and can sometimes leave bogus COM ports when disconnected. For example, I currently have no bluetooth devices connected, but if I go into device manager, I see a total of eleven COM ports listed as Bluetooth serial port The properties on each of these ports show the device as working and available, and I can usually open these ports though I get occasional failures. My work around for this is to force COM port numbers for connected deviced, through properties / advanced / COM port number. I'm not sure if the problem is driver related (IVT corp in this case) or a problem with the way Windows manages blutooth serial ports.

Sorry I couldn't be of any more help.

Shane MacLaughlin