USB to serial cables cause problems

M

mike

I have a communication program that uses 2 threads (recieve and transmit). I
have problems when using a usb to serial cable. If the serial device
attached to the cable abnormally terminates ( loses power), I have problems
when the app tries to close the com port. I have 2 different cables with 2
different problems.
1. This is the worst, when the com is closed, the send thread seems to exit
normally but does not completely clean up. ie the call to
WaitForSingleObject( hcom, INFINITE) never returns. When I unplug the usb
end of the device from the computer, the call returns normally. I've tried
just waiting a certain amount of time and exiting and deleting the thread
but the app is still in a bad state as the next time I try to access the
port the app crashes.

2. The second cable is not as bad in that is let's me close the port however
I cannot reconnect as the port seems to be stuck in some irregular state.
But at least the app doesn't crash.

In both cases I have to unplug the usb and plug it back in to get the port
to work properly again.
I'm using CreateFile() with overlapped io to communicate.
WriteFile() to send (with overlapped io)
ReadFile() to read (with overlapped io)
Using AfxBeginThread() to create the threads with m_bAutoDelete set to
FALSE.
When closing the ports PurgeCom is used to try to clear up data.
I've been using serial communications for a while and haven't had problems
until I encountered these usb to serial cables.

Does anyone know how I can safely clean up the thread instance and if there
is anyway to reset the com device from software?

Thanks
 
V

V Green

Welcome to the inconsistent/non-serial compliant
world of USB - SERIAL converters.

You have already found that
just about every one of these bad boys behaves
differently from another unless they are using the
same renamed chipset-manufacturer-supplied
driver and the same chipset.

I have given up on them - but I suspect that your answer
lies in learning how to program USB ports, NOT in how
you're dealing with the serial port.

Have fun. Programming USB is a chore. I haven't even begun
to figure it out - hot plugging and all - yeesh.
 

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

Similar Threads

USB serial port 1
PCI serial ports 8
USB to Serial 1
PCI Serial Card 16
USB to RS232 to USB adapter needed 9
USB to Serial Adapter 4
Usb to serial console port 2
USB to Serial connection 4

Top