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?

LPC1768 USB hangup
Started by ●July 7, 2012
Reply by ●July 7, 20122012-07-07
On Sat, 07 Jul 2012 12:19:04 -0700, John Larkin <jjlarkin@highNOTlandTHIStechnologyPART.com> wrote:>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.The problem is that a USB serial device can be closed by disconnecting the device, whereas a real serial port cannot. The comms program has to be aware of USB serial ports. HyperTerm is just too old. Stephen -- Stephen Pelc, stephenXXX@mpeforth.com MicroProcessor Engineering Ltd - More Real, Less Time 133 Hill Lane, Southampton SO15 5AF, England tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691 web: http://www.mpeforth.com - free VFX Forth downloads
Reply by ●July 7, 20122012-07-07
Stephen Pelc wrote:> > On Sat, 07 Jul 2012 12:19:04 -0700, John Larkin > <jjlarkin@highNOTlandTHIStechnologyPART.com> wrote: > > >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. > > The problem is that a USB serial device can be closed by disconnecting > the device, whereas a real serial port cannot. The comms program has > to be aware of USB serial ports. HyperTerm is just too old. > > StephenI'm a big fan of Putty for this sort of job. Cheers Phil Hobbs -- Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 845-480-2058 hobbs at electrooptical dot net http://electrooptical.net
Reply by ●July 7, 20122012-07-07
On Sat, 07 Jul 2012 22:38:23 GMT, stephenXXX@mpeforth.com (Stephen Pelc) wrote:>On Sat, 07 Jul 2012 12:19:04 -0700, John Larkin ><jjlarkin@highNOTlandTHIStechnologyPART.com> wrote: > >>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. > >The problem is that a USB serial device can be closed by disconnecting >the device, whereas a real serial port cannot. The comms program has >to be aware of USB serial ports. HyperTerm is just too old. > >StephenMy PowerBasic program did the same thing. What do you mean by "be aware" ? What would a program do the prevent the hangup? Closing the open port after the disconnect is apparently too late.
Reply by ●July 7, 20122012-07-07
On Saturday, July 7, 2012 3:58:39 PM UTC-7, Phil Hobbs wrote:> Stephen Pelc wrote: > > > > On Sat, 07 Jul 2012 12:19:04 -0700, John Larkin > > <jjlarkin@highNOTlandTHIStechnologyPART.com> wrote: > > > > >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. > > > > The problem is that a USB serial device can be closed by disconnecting > > the device, whereas a real serial port cannot. The comms program has > > to be aware of USB serial ports. HyperTerm is just too old. > > > > Stephen > > I'm a big fan of Putty for this sort of job. >Putty has the same issue. It's a window problem.
Reply by ●July 7, 20122012-07-07
On 7/7/2012 5:00 PM, John Larkin wrote:> On Sat, 07 Jul 2012 22:38:23 GMT, stephenXXX@mpeforth.com (Stephen > Pelc) wrote: > >> On Sat, 07 Jul 2012 12:19:04 -0700, John Larkin >> <jjlarkin@highNOTlandTHIStechnologyPART.com> wrote: >> >>> 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. >> >> The problem is that a USB serial device can be closed by disconnecting >> the device, whereas a real serial port cannot. The comms program has >> to be aware of USB serial ports. HyperTerm is just too old. >> >> Stephen > > My PowerBasic program did the same thing. What do you mean by "be > aware" ? What would a program do the prevent the hangup? Closing the > open port after the disconnect is apparently too late. > >There is NO program on ANY operating system that can survive a USB serial port disconnect. I have tried many, wrote some of my own. Windoze, Linux, CE, none can survive without a program restart. hamilton
Reply by ●July 7, 20122012-07-07
[This followup was posted to sci.electronics.design and a copy was sent to the cited author.] In article <ha2hv75jdv48e93fib3jdv11lof2dup08k@4ax.com>, jjlarkin@highNOTlandTHIStechnologyPART.com 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
Reply by ●July 7, 20122012-07-07
On Sat, 07 Jul 2012 19:03:57 -0600, hamilton <hamilton@nothere.com> wrote:>On 7/7/2012 5:00 PM, John Larkin wrote: >> On Sat, 07 Jul 2012 22:38:23 GMT, stephenXXX@mpeforth.com (Stephen >> Pelc) wrote: >> >>> On Sat, 07 Jul 2012 12:19:04 -0700, John Larkin >>> <jjlarkin@highNOTlandTHIStechnologyPART.com> wrote: >>> >>>> 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. >>> >>> The problem is that a USB serial device can be closed by disconnecting >>> the device, whereas a real serial port cannot. The comms program has >>> to be aware of USB serial ports. HyperTerm is just too old. >>> >>> Stephen >> >> My PowerBasic program did the same thing. What do you mean by "be >> aware" ? What would a program do the prevent the hangup? Closing the >> open port after the disconnect is apparently too late. >> >> > >There is NO program on ANY operating system that can survive a USB >serial port disconnect. > >I have tried many, wrote some of my own. > >Windoze, Linux, CE, none can survive without a program restart. > >hamiltonGoing into Device Manager and disabling/enabling the port fixes the hangup. Maybe there is a command-line equivalent. If so, I could shell out to that. This maybe? http://support.microsoft.com/kb/311272
Reply by ●July 7, 20122012-07-07
In article <jtama2$9s1$1@dont-email.me>, hamilton@nothere.com says...> > On 7/7/2012 5:00 PM, John Larkin wrote: > > On Sat, 07 Jul 2012 22:38:23 GMT, stephenXXX@mpeforth.com (Stephen > > Pelc) wrote: > > > >> On Sat, 07 Jul 2012 12:19:04 -0700, John Larkin > >> <jjlarkin@highNOTlandTHIStechnologyPART.com> wrote: > >> > >>> 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. > >> > >> The problem is that a USB serial device can be closed by disconnecting > >> the device, whereas a real serial port cannot. The comms program has > >> to be aware of USB serial ports. HyperTerm is just too old. > >> > >> Stephen > > > > My PowerBasic program did the same thing. What do you mean by "be > > aware" ? What would a program do the prevent the hangup? Closing the > > open port after the disconnect is apparently too late. > > > > > > There is NO program on ANY operating system that can survive a USB > serial port disconnect. > > I have tried many, wrote some of my own. > > Windoze, Linux, CE, none can survive without a program restart. > > hamiltonWriting your own serial emulator talking to the device driver meant for a USB serial chip can help SOMETIMES. Otherwise checking handles, and device drivers before nearly every call or putting timeouts on serial port transactions can help. Make sure you have a tiemout handler to close and open device. Timeouts have existed on most serial ports and printer ports on most operating systems for a long time. How well they work depends on the operating system and its drivers as well as the USB driver. Some drivers have a call to cycle the device from the driver, which might help depending on how well written the driver is. -- Paul Carpenter | paul@pcserviceselectronics.co.uk <http://www.pcserviceselectronics.co.uk/> PC Services <http://www.pcserviceselectronics.co.uk/fonts/> Timing Diagram Font <http://www.gnuh8.org.uk/> GNU H8 - compiler & Renesas H8/H8S/H8 Tiny <http://www.badweb.org.uk/> For those web sites you hate
Reply by ●July 7, 20122012-07-07
"John Larkin" <jjlarkin@highNOTlandTHIStechnologyPART.com> wrote in message news:ha2hv75jdv48e93fib3jdv11lof2dup08k@4ax.com...> > > 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? > > >I have a similar problem with a Microchip USB stack. It's not serial emulation. If the device is unplugged the calls on the host may hang, and the whole host controller is hung. Windows will not shutdown, and is stuck on the USB hung call. The multithreaded routine that Mike explains seem to be the only solution. You could do a 'try' 'catch', but if there is no exception thrown then it's useless. Cheers
