I am having an issue with closing a serial port in VB.NET. Here is how I close the port:
The problem is that another application (I will call it Application X) we use after my program has fully exited still can not get the com port. I think the problem is with Application X not properly (or fully) initializing the com port - however when Hyperterminal is finished with the port Application X works fine. Hyperterminal also has no problem with the com port after my application - it's only Application X that appears to have a problem with the com port after my VB.NET application has been using it (and closes it as per the above code).
Here's how Application X open the serial Port:
That code is handled by another division in the company so I have no control over it...
Also - it is already deployed (1000+ installations). ..
Thanks to anyone who can help.
Is there something I am not doing (or could do) to leave the com port in the same state Hyperterminal does?
Code:
If spPort.IsOpen = True Then spPort.DiscardInBuffer() spPort.DtrEnable = False spPort.RtsEnable = False spPort.Close() End If spPort.Dispose()
Here's how Application X open the serial Port:
Code:
m_serialPort = CreateFile( portStr.c_str(), GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
Also - it is already deployed (1000+ installations). ..
Thanks to anyone who can help.
Is there something I am not doing (or could do) to leave the com port in the same state Hyperterminal does?