diff --git a/mdl/m_io_base.pas b/mdl/m_io_base.pas index 5a26428..1bc03d6 100644 --- a/mdl/m_io_base.pas +++ b/mdl/m_io_base.pas @@ -16,10 +16,11 @@ Type FInBufEnd : LongInt; FOutBuf : TIOBuffer; FOutBufPos : LongInt; + Connected : Boolean; Constructor Create; Virtual; Destructor Destroy; Override; - Procedure PurgeInputData (Drain: Boolean); + Procedure PurgeInputData (DrainWait: LongInt); Procedure PurgeOutputData; Function DataWaiting : Boolean; Virtual; Function WriteBuf (Var Buf; Len: LongInt) : LongInt; Virtual; @@ -37,6 +38,9 @@ Type Implementation +Uses + m_DateTime; + Constructor TIOBase.Create; Begin Inherited Create; @@ -44,6 +48,7 @@ Begin FInBufPos := 0; FInBufEnd := 0; FOutBufPos := 0; + Connected := True; End; Destructor TIOBase.Destroy; @@ -56,18 +61,21 @@ Begin FOutBufPos := 0; End; -Procedure TIOBase.PurgeInputData (Drain: Boolean); +Procedure TIOBase.PurgeInputData (DrainWait: LongInt); Var Buf : Array[1..2048] of Char; Begin FInBufPos := 0; FInBufEnd := 0; - If Drain Then - While DataWaiting Do Begin + If DrainWait > 0 Then Begin + DrainWait := TimerSet(DrainWait); + + While DataWaiting And Not TimerUp(DrainWait) Do Begin ReadBuf(Buf, SizeOf(Buf)); If FInBufEnd <= 0 Then Break; End; + End; End; Function TIOBase.DataWaiting : Boolean;