//--------------------------------------------------------------------- // GetResponse() //--------------------------------------------------------------------- private static int GetResponse( clsSerialPort pobjPort, ref bool pbResult ) { int iResponse = -1; pbResult = false; // Test-mode if ( bTestMode == true ) { pbResult = true; return c*K; } // int iStartTime = System.Environment.TickCount; while ( pobjPort.inBufferCount < 1 && System.Environment.TickCount - iStartTime < 2000 && bAbort == false ) { Application.DoEvents(); } // Abort if ( bAbort == true ) { return -1; } // Timeout if ( pobjPort.inBufferCount < 1 ) { OnDownloading( new clsDownloadingEventArgs(clsDownloadingEventArgs.EventType.error, "response timed out", -1) ); return -1; } pobjPort.ReadByte( ref iResponse ); pbResult = true; return iResponse; }