Ignore:
Timestamp:
Aug 30, 2011, 3:50:15 PM (13 years ago)
Author:
george
Message:
  • Fixed: Do not send or receive data for comm classes if not in active state.
  • Fixed: TCommProtocol now raise ENotActive exception on try to send data while in inactive state.
  • Fixed: Reseting event after data received in TCommThread class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/UCommThread.pas

    r231 r272  
    1919  public
    2020    Parent: TCommThread;
    21     Stream: TMemoryStream;
     21    Stream: TStreamHelper;
    2222    procedure Execute; override;
    2323    constructor Create(CreateSuspended: Boolean;
     
    5353procedure TCommThread.ReceiveData(Sender: TCommPin; Stream:TStream);
    5454begin
    55   Ext.Send(Stream);
     55  if FActive then Ext.Send(Stream);
    5656end;
    5757
     
    115115
    116116procedure TCommThreadReceiveThread.Execute;
    117 var
    118   StreamHelper: TStreamHelper;
    119117begin
    120118  try
    121     StreamHelper := TStreamHelper.Create(Stream);
    122119    with Parent do
    123120    repeat
    124       if FDataAvailable.WaitFor(1) = wrSignaled then begin
     121      if FDataAvailable.WaitFor(1) = wrSignaled then
    125122      try
    126123        FInputBufferLock.Acquire;
    127124        Stream.Size := 0;
    128         StreamHelper.WriteStream(FInputBuffer, FInputBuffer.Size);
     125        Stream.WriteStream(FInputBuffer, FInputBuffer.Size);
    129126        Pin.Send(Stream);
     127      finally
     128        FDataAvailable.ResetEvent;
    130129        FInputBuffer.Clear;
    131       finally
    132130        FInputBufferLock.Release;
    133       end;
    134131      end; // else Yield;
    135132    until Terminated;
    136133  finally
    137     StreamHelper.Free;
    138134  end;
    139135end;
     
    143139begin
    144140  inherited;
    145   Stream := TMemoryStream.Create;
     141  Stream := TStreamHelper.Create;
    146142end;
    147143
Note: See TracChangeset for help on using the changeset viewer.