Ignore:
Timestamp:
Nov 19, 2012, 2:43:40 PM (12 years ago)
Author:
chronos
Message:
  • Fixed: Thread safe access to serial port pin interface using lock.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/UCommTelnet.pas

    r416 r440  
    66
    77uses
    8   Classes, SysUtils, UCommPin, SpecializedList, DateUtils, UStreamHelper,
    9   SpecializedStream, UBinarySerializer;
     8  Classes, SysUtils, UCommPin, SpecializedList, DateUtils, Dialogs,
     9  UBinarySerializer;
    1010
    1111type
     
    7474    FState: TTelnetState;
    7575    FCommandData: TBinarySerializer;
    76     procedure SetActive(AValue: Boolean);
    7776    procedure TelnetDataReceive(Sender: TCommPin; Stream: TListByte);
    7877    procedure RawDataReceive(Sender: TCommPin; Stream: TListByte);
     
    8079    function ResponseCount: Integer;
    8180  protected
     81    procedure SetActive(const AValue: Boolean); override;
    8282    procedure AssignTo(Dest: TPersistent); override;
    8383  public
     
    153153    RequestData.Free;
    154154  end;
     155  Result := SupportedByServer;
    155156end;
    156157
     
    159160  RequestData: TBinarySerializer;
    160161  ResponseData: TBinarySerializer;
    161   I: Integer;
    162162begin
    163163  if Telnet.OptionsNegotationEnable then CheckOption;
     
    210210end;
    211211
    212 procedure TCommTelnet.SetActive(AValue: Boolean);
     212procedure TCommTelnet.SetActive(const AValue: Boolean);
    213213var
    214214  I: Integer;
     
    376376end;
    377377
     378function ByteToStr(Value: Byte): string;
     379begin
     380  Result := IntToStr(Value);
     381end;
     382
    378383procedure TCommTelnet.SendCommand(Code: TTelnetCode; Request,
    379384  Response: TListByte);
     
    405410      if Code = tcSB then begin
    406411        if (Response[Response.Count - 2] <> Byte(tcIAC)) or
    407         (Response[Response.Count - 1] <> Byte(tcSE)) then
     412        (Response[Response.Count - 1] <> Byte(tcSE)) then begin
     413          ShowMessage(Response.Implode(' ', ByteToStr));
     414          ReadResponse(Response);
     415          ShowMessage(Response.Implode(' ', ByteToStr));
    408416          raise Exception.Create(SWrongResponse);
     417        end;
    409418        Response.DeleteItems(Response.Count - 2, 2);
    410419      end;
    411420      // Remove IAC escape character from data
    412421      I := 0;
     422      LastIAC := False;
    413423      while (I < Response.Count) do begin
    414424        if Response[I] = Byte(tcIAC) then begin
Note: See TracChangeset for help on using the changeset viewer.