COM port disappears

R

Richard Swinfen

I have written an application which uses the COM port COM1. It normally
works fine, but occasionally after I shut down the application and attempt
to restart it, the COM1 port disappears.

DOS can't see it either and anything that attempts to access it returns the
error code 67 ERROR_BAD_NET_NAME or "The network name cannot be found".

The only resolution is to restart Windows. When it happens I've tried
reassigning the COM port to a different number, disabling and re-enabling
the port through the hardware devices interface, to see if that 'resets' it,
but it still doesn't reappear.

If there was some way of determining the state of the port, or what might be
going wrong when I shut down the application, that might help me towards a
solution.

Any help much appreciated.

Richard.
 
O

Opa

From the way you describe the problem, it seems that your application does
nor restore the COM-port to it original settings when you quit the
application or when it hangs. Make sure you don't use COM1 and COM3 or COM2
and COM4 at the same time.
 
R

Richard Swinfen

Opa said:
From the way you describe the problem, it seems that your application does
nor restore the COM-port to it original settings when you quit the
application or when it hangs. Make sure you don't use COM1 and COM3 or
COM2 and COM4 at the same time.

Just use COM1. I certainly close the handle on exit and even if I didn't,
of course 'Windows' would close all the application's handles anyway. Are
you suggesting that I need to restore the baud rate, parity, cts etc.
settings as well? Not sure why that would be necessary nor why it would
cause this to happen?!

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top