Reply by Mario July 15, 20122012-07-15
W dniu 2012-07-08 01:00, John Larkin pisze:
> 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. >
Hi. Use terminal v1.9b by Br@y++. It can close virtual port after disconnecting usb cable. -- Regards MD
Reply by josephkk July 10, 20122012-07-10
On Sat, 07 Jul 2012 12:19:04 -0700, John Larkin
<jjlarkin@highNOTlandTHIStechnologyPART.com> wrote:

> > >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? >
My first guess is that Winders does not properly comply with the USB specification, or that the specification itself has problems with disconnect followed by reconnect. Fortunately the USB specification is publicly available from the USB consortium. ?-)
Reply by Stephen Pelc July 9, 20122012-07-09
On Sun, 08 Jul 2012 11:30:50 GMT, stephenXXX@mpeforth.com (Stephen
Pelc) wrote:

>It's been a while since I rewrote our terminal emulator for USB. >I think that we check the error code returned by ClearCommError(), and >check for CE_MODE. If this is set, the channel has been disconnected >and you should close the comms.
It now turns out that ClearCommError() returns 0 if a USB serial port is disconnected. This fits well with the current Windows documentation. Our terminal emulator now closes the port gracefully when the USB adapter is diconnected. 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 Stephen Pelc July 9, 20122012-07-09
On Sun, 08 Jul 2012 11:31:34 GMT, stephenXXX@mpeforth.com (Stephen
Pelc) wrote:

>On Sat, 07 Jul 2012 19:03:57 -0600, hamilton <hamilton@nothere.com> >wrote: > >>Windoze, Linux, CE, none can survive without a program restart. > >Would you like me to demonstrate?
Well, I may have to apologise! I have checked our code again on Win7-64 and XP SP3 with a Keyspan USA-19HS and a generic Prolific (branded Nikkai) USB serial port. Both PCs are fully updated. We're in the middle of an office refurb, so I have no easy access to other PCs or USB serial adapters. In both cases, neither PC generates any error bits in the variable specified by ClearCommError(). The controlling program still survives the experiences. The original code is marked as 2005 in the change markers and was throughly tested at the time. Oh, dear. There's a 1998 MSDN CD set somewhere ... I knew I shouldn't have thrown out the more recent ones ... 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 krw...@att.bizzzzzzzzzzzz July 8, 20122012-07-08
On Sun, 08 Jul 2012 09:07:45 -0700, John Larkin
<jjlarkin@highNOTlandTHIStechnologyPART.com> wrote:

>On Sun, 08 Jul 2012 11:30:50 GMT, stephenXXX@mpeforth.com (Stephen >Pelc) wrote: > >>On Sat, 07 Jul 2012 16:00:36 -0700, John Larkin >><jjlarkin@highNOTlandTHIStechnologyPART.com> wrote: >> >>>>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. >> >>It's been a while since I rewrote our terminal emulator for USB. >>I think that we check the error code returned by ClearCommError(), and >>check for CE_MODE. If this is set, the channel has been disconnected >>and you should close the comms. >> >>Stephen > >I can close the port manually, and re-open it, or kill the program and >restart it, but the thing is still hung. I have to use Device Manager >to disable/reenable the comm port before it will work again.
I had that problem with a Delorme BlueTooth GPS thingy. I ended up throwing it away because it wasn't usable.
Reply by John Larkin July 8, 20122012-07-08
On Sun, 08 Jul 2012 11:30:50 GMT, stephenXXX@mpeforth.com (Stephen
Pelc) wrote:

>On Sat, 07 Jul 2012 16:00:36 -0700, John Larkin ><jjlarkin@highNOTlandTHIStechnologyPART.com> wrote: > >>>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. > >It's been a while since I rewrote our terminal emulator for USB. >I think that we check the error code returned by ClearCommError(), and >check for CE_MODE. If this is set, the channel has been disconnected >and you should close the comms. > >Stephen
I can close the port manually, and re-open it, or kill the program and restart it, but the thing is still hung. I have to use Device Manager to disable/reenable the comm port before it will work again.
Reply by Stephen Pelc July 8, 20122012-07-08
On Sun, 08 Jul 2012 06:26:49 -0600, hamilton <hamilton@nothere.com>
wrote:

>> Would you like me to demonstrate? >> >> Stephen >> >Sharing you code would be helpful.
The important bits for Windows with VC6: // ================================================================= // Serial line routines - these simulate the Forth KEY KEY? and EMIT // No attempt at efficiency is made - the PC always gets faster, and // we can improve these at a later date. // ================================================================= int TargetError=0; // set when target reports error // return number of characters in serial input queue DWORD SerKeyQ( void ) { DWORD ErrorCode; COMSTAT cstat; if (ThrowReason != 0) { ErrorCode=ThrowReason; ThrowReason = 0; throw( ErrorCode ); } if (bClosing) return 0; if (hCom == INVALID_HANDLE_VALUE) return 0; if (hCom == NULL) return 0; if (!bConnected) return 0; ClearCommError( hCom, &ErrorCode, &cstat ); if( ErrorCode & CE_MODE ) // check for close; SFP009 { hCom=NULL; bConnected=FALSE; WriteStatus( "Comms closed", 1 ); return 0; } return (cstat.cbInQue); } // return next character in serial input queue char SerKey( void ) { DWORD bytesdone; char Buffer[4]; while ( SerKeyQ()==0 ) { if (hCom == INVALID_HANDLE_VALUE) return 0x0D; if (hCom == NULL) return 0x0D; if (!bConnected) return 0x0D; // Sleep(10); Sleep(5); if (bClosing) return 0x0D; } ReadFile( hCom, Buffer, 1, &bytesdone, NULL ); return (Buffer[0]); } Showing you the whole lot will show you how to write a mixed Forth and C application which is now being converted to pure Forth because debugging this sort of stuff is so much easier in Forth than in C. 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 hamilton July 8, 20122012-07-08
On 7/8/2012 5:31 AM, Stephen Pelc wrote:
> On Sat, 07 Jul 2012 19:03:57 -0600, hamilton <hamilton@nothere.com> > wrote: > >> Windoze, Linux, CE, none can survive without a program restart. > > Would you like me to demonstrate? > > Stephen >
Sharing you code would be helpful. hamilton
Reply by Stephen Pelc July 8, 20122012-07-08
On Sat, 07 Jul 2012 19:03:57 -0600, hamilton <hamilton@nothere.com>
wrote:

>Windoze, Linux, CE, none can survive without a program restart.
Would you like me to demonstrate? 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 Stephen Pelc July 8, 20122012-07-08
On Sat, 07 Jul 2012 16:00:36 -0700, John Larkin
<jjlarkin@highNOTlandTHIStechnologyPART.com> wrote:

>>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.
It's been a while since I rewrote our terminal emulator for USB. I think that we check the error code returned by ClearCommError(), and check for CE_MODE. If this is set, the channel has been disconnected and you should close the comms. 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