[This followup was posted to sci.electronics.design and a copy was sent
to the cited author.]
In article <>,
says...
>
> We built a little picosecond pulse generator box with a USB interface.
> The USB is directly into an LPC1768 NXP ARM chip, and we're using the
> USB stack and inf file that Code Red provided. It enumerates as a
> serial port. It's "unsupported", which means it's *really*
> unsupported.
>
> Under Windows XP, there's a small glitch. I can plug/unplug the USB
> cable, and it always makes all the proper bleep/bloop
> connect/disconnect noises. It shows up as COM6 or some such. I can
> talk to it from Hyperterminal or from a PowerBasic program. But if I
> disconnect the USB cable while the port is open, it hangs up. The fix
> is to close the program, then go to Device Manager, disable it, and
> re-enable it.
>
> I've seen other USB devices behave this way, too.
>
> Anybody know what's going on, and maybe how to fix it?
This is an annoying and complex problem that, as far as I know, does not
yet have a good solution from the operating system standpoint. I am not
totally sure what the root of the problem is but it could very well be
related to the type of combo drivers that are used to support USB/COMM
port type devices.
At the company where I work we had the very same problem as you have
described with a USB port connected into an external box where the USB
terminated into a 1->4 USB hub and then into an FT232R chip that then
went TTL serial port to a SiLabs MCU. The fix that was used was to
compose the host side program as multiple threads where the thread that
managed the "virtual serial COM port out USB" could be unloaded and
restarted from another monitoring thread. The monitoring thread kept an
ongoing heartbeat packet sent to the external device whenever there was
no normal serial traffic going on. If the serial traffic, either normal
or the heartbeat type, ever encountered an error due to sudden removal
of the USB cable the monitoring thread would unload the thread that
owned the crashed virtual comm port. It would then use some API calls
that are available to automate the same things you do in device manager
to to disable/enable the port. Then finally it could reload the thread
that managed the Comm port whilst it waited for the device to reappear
as connected.
Needless to say this was a complex solution to make the usage model of
the software a whole lot more user friendly. Without that the use of USB
Serial devices basically sucks if you suddenly unplug the USB cable
whilst it is in use.
Michael Karas
--
Michael Karas
Carousel Design Solutions
http://www.carousel-design.com