Changeset 411 for PinConnection


Ignore:
Timestamp:
Aug 16, 2012, 9:54:23 AM (12 years ago)
Author:
chronos
Message:
Location:
PinConnection
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/Languages/UCommTelnet.po

    r408 r411  
    22msgstr "Content-Type: text/plain; charset=UTF-8"
    33
     4#: ucommtelnet.soptionnotfound
     5msgid "Option not found"
     6msgstr ""
     7
     8#: ucommtelnet.stimeout
     9msgid "Telnet command timout"
     10msgstr ""
     11
    412#: ucommtelnet.sunknownstate
    513msgid "Unknown state"
     14msgstr ""
     15
     16#: ucommtelnet.swrongresponse
     17msgid "Wrong response"
     18msgstr ""
     19
     20#: ucommtelnet.swrongresponsecode
     21msgid "Wrong response code"
    622msgstr ""
    723
  • PinConnection/PinConnection.lpk

    r410 r411  
    2424    <Files Count="14">
    2525      <Item1>
     26        <Filename Value="USerialPort.pas"/>
     27        <UnitName Value="USerialPort"/>
     28      </Item1>
     29      <Item2>
     30        <Filename Value="UPacketBurst.pas"/>
     31        <UnitName Value="UPacketBurst"/>
     32      </Item2>
     33      <Item3>
    2634        <Filename Value="UCommFrame.pas"/>
    2735        <UnitName Value="UCommFrame"/>
    28       </Item1>
    29       <Item2>
     36      </Item3>
     37      <Item4>
    3038        <Filename Value="UCommHub.pas"/>
    3139        <UnitName Value="UCommHub"/>
    32       </Item2>
    33       <Item3>
     40      </Item4>
     41      <Item5>
    3442        <Filename Value="UCommPin.pas"/>
    3543        <UnitName Value="UCommPin"/>
    36       </Item3>
    37       <Item4>
     44      </Item5>
     45      <Item6>
    3846        <Filename Value="UCommSerialPort.pas"/>
    3947        <UnitName Value="UCommSerialPort"/>
    40       </Item4>
    41       <Item5>
     48      </Item6>
     49      <Item7>
    4250        <Filename Value="UCommThread.pas"/>
    4351        <UnitName Value="UCommThread"/>
    44       </Item5>
    45       <Item6>
    46         <Filename Value="UPacketBurst.pas"/>
    47         <UnitName Value="UPacketBurst"/>
    48       </Item6>
    49       <Item7>
    50         <Filename Value="USerialPort.pas"/>
    51         <UnitName Value="USerialPort"/>
    5252      </Item7>
    5353      <Item8>
  • PinConnection/PinConnection.pas

    r410 r411  
    88
    99uses
    10   UCommFrame, UCommHub, UCommPin, UCommSerialPort, UCommThread, UPacketBurst,
    11   USerialPort, UCommConcentrator, UCommDelay, UCommTCPClient, UCommTCPServer,
     10  USerialPort, UPacketBurst, UCommFrame, UCommHub, UCommPin, UCommSerialPort,
     11  UCommThread, UCommConcentrator, UCommDelay, UCommTCPClient, UCommTCPServer,
    1212  UCommTelnet, UCommTelnetComPortOption, UCommMark, LazarusPackageIntf;
    1313
  • PinConnection/UCommFrame.pas

    r407 r411  
    105105    if Random >= PacketLoss then
    106106      RawDataPin.Send(RawData.List);
    107 
    108107  finally
    109108    RawData.Free;
  • PinConnection/UCommTCPClient.pas

    r407 r411  
    6161      Mem := TMemoryStream.Create;
    6262      Stream.WriteToStream(Mem);
     63      Mem.Position := 0;
    6364      Socket.SendStreamRaw(Mem);
    6465    finally
  • PinConnection/UCommTelnet.pas

    r408 r411  
    4848  TTelnetOption = class
    4949  private
     50    FActive: Boolean;
    5051    FOnRequest: TTelnetOptionEvent;
     52  protected
     53    procedure SetActive(AValue: Boolean); virtual;
    5154  public
    5255    Telnet: TCommTelnet;
    53     Code: TTelnetOption;
     56    Code: TTelnetCommand;
    5457    ServerChecked: Boolean;
    55     ServerSupport: Boolean;
     58    SupportedByServer: Boolean;
     59    function CheckOption: Boolean;
     60    procedure SendCommand(Request, Response: TListByte);
    5661    property OnRequest: TTelnetOptionEvent read FOnRequest write FOnRequest;
    57   end;
    58 
    59   { TTelnetOptionList }
     62    property Active: Boolean read FActive write SetActive;
     63  end;
     64
     65  TTelnetPortType = (ptClient, ptServer);
    6066
    6167  { TCommTelnet }
     
    6369  TCommTelnet = class
    6470  private
     71    FResponses: TListObject; // TListObject<TListByte>
     72    FActive: Boolean;
    6573    FState: TTelnetState;
    66     FCommandData: TStreamHelper;
    67     procedure TelnetDataReceive(Sender: TCommPin; Stream: TStream);
    68     procedure RawDataReceive(Sender: TCommPin; Stream: TStream);
     74    FCommandData: TBinarySerializer;
     75    procedure SetActive(AValue: Boolean);
     76    procedure TelnetDataReceive(Sender: TCommPin; Stream: TListByte);
     77    procedure RawDataReceive(Sender: TCommPin; Stream: TListByte);
     78    procedure ReadResponse(Response: TListByte);
     79    function ResponseCount: Integer;
    6980  public
    7081    Options: TListObject;
     
    7283    RawPin: TCommPin;
    7384    Timeout: TDateTime;
     85    PortType: TTelnetPortType;
     86    ErrorCount: Integer;
    7487    procedure Register(Option: TTelnetOption);
    7588    procedure Unregister(Option: TTelnetOption);
    76     function CheckOption(Option: TTelnetCommand): Boolean;
    77     procedure SendSubCommand(Option: TTelnetCommand; Request, Response: TListByte);
     89    function CheckOption(OptionCode: TTelnetCommand): Boolean;
     90    function SearchOption(OptionCode: TTelnetCommand): TTelnetOption;
     91    procedure SendSubCommand(OptionCode: TTelnetCommand; Request, Response: TListByte);
    7892    procedure SendCommand(Code: TTelnetCode; Request, Response: TListByte);
    7993    constructor Create;
    8094    destructor Destroy; override;
     95    property Active: Boolean read FActive write SetActive;
    8196  end;
    8297
     
    87102  SUnknownState = 'Unknown state';
    88103  SWrongResponseOption = 'Wrong response option';
     104  SWrongResponseCode = 'Wrong response code';
     105  SWrongResponse = 'Wrong response';
     106  SOptionNotFound = 'Option not found';
     107  STimeout = 'Telnet command timout';
     108
     109{ TTelnetOption }
     110
     111procedure TTelnetOption.SetActive(AValue: Boolean);
     112begin
     113  if FActive = AValue then Exit;
     114  FActive := AValue;
     115end;
     116
     117function TTelnetOption.CheckOption: Boolean;
     118var
     119  RequestData: TBinarySerializer;
     120  ResponseData: TBinarySerializer;
     121begin
     122  if not ServerChecked then
     123  try
     124    RequestData := TBinarySerializer.Create;
     125    RequestData.List := TListByte.Create;
     126    RequestData.OwnsList := True;
     127    ResponseData := TBinarySerializer.Create;
     128    ResponseData.List := TListByte.Create;
     129    ResponseData.OwnsList := True;
     130
     131    RequestData.WriteByte(Byte(Code));
     132    Telnet.SendCommand(tcDo, RequestData.List, ResponseData.List);
     133    if ResponseData.List[0] = Byte(tcWILL) then SupportedByServer := True
     134      else if ResponseData.List[0] = Byte(tcWONT) then SupportedByServer := False
     135      else raise Exception.Create(SWrongResponse);
     136    ServerChecked := True;
     137  finally
     138    RequestData.Free;
     139    RequestData.Free;
     140  end;
     141end;
     142
     143procedure TTelnetOption.SendCommand(Request, Response: TListByte);
     144var
     145  RequestData: TBinarySerializer;
     146  ResponseData: TBinarySerializer;
     147  I: Integer;
     148begin
     149  CheckOption;
     150  try
     151    RequestData := TBinarySerializer.Create;
     152    RequestData.List := TListByte.Create;
     153    RequestData.OwnsList := True;
     154    ResponseData := TBinarySerializer.Create;
     155    ResponseData.List := TListByte.Create;
     156    ResponseData.OwnsList := True;
     157
     158    RequestData.WriteByte(Byte(Code));
     159    RequestData.WriteList(Request, 0, Request.Count);
     160    Telnet.SendCommand(tcSB, RequestData.List, ResponseData.List);
     161    if ResponseData.List[0] <> Byte(Code) then
     162      raise Exception.Create(SWrongResponseOption);
     163    ResponseData.List.Delete(0);
     164    Response.Assign(ResponseData.List);
     165  finally
     166    RequestData.Free;
     167    RequestData.Free;
     168  end;
     169end;
    89170
    90171{ TCommTelnet }
    91172
    92 procedure TCommTelnet.TelnetDataReceive(Sender: TCommPin; Stream: TStream);
     173procedure TCommTelnet.TelnetDataReceive(Sender: TCommPin; Stream: TListByte);
    93174var
    94175  Data: Byte;
    95176  RawData: TBinarySerializer;
     177  I: Integer;
    96178begin
    97179  try
     
    99181    RawData.List := TListByte.Create;
    100182    RawData.OwnsList := True;
    101     Stream.Position := 0;
    102     while Stream.Position < Stream.Size do begin
    103       Data := Stream.ReadByte;
     183    for I := 0 to Stream.Count - 1 do begin
     184      Data := Stream[I];
    104185      if Data = Byte(tcIAC) then begin
    105186        RawData.WriteByte(Byte(tcIAC));
     
    113194end;
    114195
    115 procedure TCommTelnet.RawDataReceive(Sender: TCommPin; Stream: TStream);
     196procedure TCommTelnet.SetActive(AValue: Boolean);
     197var
     198  I: Integer;
     199begin
     200  if FActive = AValue then Exit;
     201  FActive := AValue;
     202  for I := 0 to Options.Count - 1 do
     203    TTelnetOption(Options[I]).Active := AValue;
     204end;
     205
     206procedure TCommTelnet.RawDataReceive(Sender: TCommPin; Stream: TListByte);
    116207var
    117208  Data: Byte;
    118209  RawData: TBinarySerializer;
     210  I: Integer;
    119211begin
    120212  try
     
    123215    RawData.OwnsList := True;
    124216
    125     Stream.Position := 0;
    126     while Stream.Position < Stream.Size do begin
    127       Data := Stream.ReadByte;
     217    for I := 0 to Stream.Count - 1 do begin
     218      Data := Stream[I];
    128219      if FState = tsNormal then begin
    129         if Data = Byte(tcIAC) then FState := tsIAC
    130           else RawData.WriteByte(Data);
     220        if Data = Byte(tcIAC) then begin
     221          FCommandData.Clear;
     222          FState := tsIAC;
     223        end else RawData.WriteByte(Data);
    131224      end else
    132225      if FState = tsIAC then begin
    133226        if Data = Byte(tcSB) then begin
     227          // Subnegotation
     228          FCommandData.WriteByte(Data);
    134229          FState := tsSB;
    135           FCommandData.Size := 0;
    136         end
    137         else if Data = Byte(tcDO) then begin
     230        end else
     231        if (Data = Byte(tcWILL)) or (Data = Byte(tcDONT)) or (Data = Byte(tcWONT)) or (Data = Byte(tcDO))
     232        then begin
     233          // Three byte negotation commands
    138234          FCommandData.WriteByte(Data);
    139235          FState := tsOption;
    140236        end else
    141         if Data = Byte(tcDONT) then begin
     237        if (Data = Byte(tcAYT)) or (Data = Byte(tcNOP)) or (Data = Byte(tcGA)) or
     238        (Data = Byte(tcEL)) or (Data = Byte(tcEC)) or (Data = Byte(tcAO)) or
     239        (Data = Byte(tcIP)) or (Data = Byte(tcBREAK)) or (Data = Byte(tcDATA_MARK)) or
     240        (Data = Byte(tcEOR)) then begin
     241          // Two byte commands
    142242          FCommandData.WriteByte(Data);
    143           FState := tsOption;
     243          FResponses.AddNew(TListByte.Create);
     244          TListByte(FResponses.Last).Assign(FCommandData.List);         FState := tsNormal;
    144245        end else
    145         if Data = Byte(tcWONT) then begin
    146           FCommandData.WriteByte(Data);
    147           FState := tsOption;
    148         end else FState := tsNormal;
     246          FState := tsNormal;
    149247      end else
    150248      if FState = tsSB then begin
     249        // Data inside subnegotation
    151250        if Data = Byte(tcIAC) then FState := tsSB_IAC
    152         else FCommandData.WriteByte(Data);
     251          else FCommandData.WriteByte(Data);
    153252      end else
    154253      if FState = tsSB_IAC then begin
     254        // End of subnegotation data
    155255        if Data = Byte(tcSE) then begin
     256          FResponses.AddNew(TListByte.Create);
     257          TListByte(FResponses.Last).Assign(FCommandData.List);
    156258          FState := tsNormal;
    157         end else
    158 
     259        end else begin
     260          Inc(ErrorCount);
     261          FState := tsNormal;
     262        end;
    159263      end else
    160264      if FState = tsOption then begin
     265        // Third byte of negotation
    161266        FCommandData.WriteByte(Data);
     267        FResponses.AddNew(TListByte.Create);
     268        TListByte(FResponses.Last).Assign(FCommandData.List);
    162269        FState := tsNormal;
    163270      end else raise Exception.Create(SUnknownState);
     
    169276end;
    170277
     278procedure TCommTelnet.ReadResponse(Response: TListByte);
     279var
     280  TimeStart: TDateTime;
     281  ElapsedTime: TDateTime;
     282begin
     283  TimeStart := Now;
     284  repeat
     285    ElapsedTime := Now - TimeStart;
     286  until (ElapsedTime > Timeout) or (ResponseCount > 0);
     287  if ElapsedTime > Timeout then
     288    raise Exception.Create(STimeout);
     289  Response.Assign(TListByte(FResponses.First));
     290  FResponses.Delete(0);
     291end;
     292
     293function TCommTelnet.ResponseCount: Integer;
     294begin
     295  Result := FResponses.Count;
     296end;
     297
    171298procedure TCommTelnet.Register(Option: TTelnetOption);
    172299begin
     
    180307end;
    181308
    182 function TCommTelnet.CheckOption(Option: TTelnetCommand): Boolean;
    183 var
    184   Data: TBinarySerializer;
    185 begin
    186   try
    187     Data := TBinarySerializer.Create;
    188     Data.List := TListByte.Create;
    189     Data.OwnsList := True;
    190     Data.WriteByte(Byte(tcWILL));
    191     Data.WriteByte(Byte(Option));
    192     RawPin.Send(Data.List);
    193   finally
    194     Data.Free;
    195   end;
    196 end;
    197 
    198 procedure TCommTelnet.SendSubCommand(Option: TTelnetCommand; Request,
     309function TCommTelnet.CheckOption(OptionCode: TTelnetCommand): Boolean;
     310var
     311  Option: TTelnetOption;
     312begin
     313  Option := SearchOption(OptionCode);
     314  if Assigned(Option) then Result := Option.CheckOption
     315    else raise Exception.Create(SOptionNotFound);
     316end;
     317
     318function TCommTelnet.SearchOption(OptionCode: TTelnetCommand): TTelnetOption;
     319var
     320  I: Integer;
     321begin
     322  I := 0;
     323  while (I < Options.Count) and (TTelnetOption(Options[I]).Code <> OptionCode) do
     324    Inc(I);
     325  if I < Options.Count then Result := TTelnetOption(Options[I])
     326    else Result := nil;
     327end;
     328
     329procedure TCommTelnet.SendSubCommand(OptionCode: TTelnetCommand; Request,
    199330  Response: TListByte);
    200331var
    201   RequestData: TBinarySerializer;
    202   ResponseData: TBinarySerializer;
    203 begin
    204   try
    205     RequestData := TBinarySerializer.Create;
    206     RequestData.List := TListByte.Create;
    207     RequestData.OwnsList := True;
    208     ResponseData := TBinarySerializer.Create;
    209     ResponseData.List := TListByte.Create;
    210     ResponseData.OwnsList := True;
    211 
    212     RequestData.WriteByte(Byte(Option));
    213     RequestData.WriteList(Request, 0, Request.Count);
    214     RequestData.WriteByte(Byte(tcIAC));
    215     RequestData.WriteByte(Byte(tcSE));
    216     SendCommand(tcSB, RequestData.List, ResponseData.List);
    217     ResponseData.Position := 0;
    218     if ResponseData.ReadByte <> Byte(Option) then
    219       raise Exception.Create(SWrongResponseOption);
    220   finally
    221     RequestData.Free;
    222     RequestData.Free;
    223   end;
     332  Option: TTelnetOption;
     333begin
     334  Option := SearchOption(OptionCode);
     335  if Assigned(Option) then Option.SendCommand(Request, Response)
     336    else raise Exception.Create(SOptionNotFound);
    224337end;
    225338
     
    228341var
    229342  Data: TBinarySerializer;
     343  LastIAC: Boolean;
     344  I: Integer;
    230345begin
    231346  try
     
    235350    Data.WriteByte(Byte(tcIAC));
    236351    Data.WriteByte(Byte(Code));
     352    for I := 0 to Request.Count - 1 do begin
     353      if Request[I] = Byte(tcIAC) then Data.WriteByte(Byte(tcIAC));
     354      Data.WriteByte(Request[I]);
     355    end;
     356    if Code = tcSB then begin
     357      Data.WriteByte(Byte(tcIAC));
     358      Data.WriteByte(Byte(tcSE));
     359    end;
    237360    RawPin.Send(Data.List);
    238 //    repeat
    239 
    240 //    until ;
     361    if Assigned(Response) then begin
     362      ReadResponse(Response);
     363      if Response[0] <> Byte(Code) then
     364        raise Exception.Create(SWrongResponseCode);
     365      Response.Delete(0);
     366      if Code = tcSB then begin
     367        if (Response[Response.Count - 2] <> Byte(tcIAC)) or
     368        (Response[Response.Count - 1] <> Byte(tcSE)) then
     369          raise Exception.Create(SWrongResponse);
     370        Response.DeleteItems(Response.Count - 2, 2);
     371      end;
     372      // Remove IAC escape character from data
     373      I := 0;
     374      while (I < Response.Count) do begin
     375        if Response[I] = Byte(tcIAC) then begin
     376          if not LastIAC then LastIAC := True
     377          else begin
     378            LastIAC := False;
     379            Response.Delete(I);
     380            Dec(I);
     381          end;
     382        end;
     383        Inc(I);
     384      end;
     385    end;
    241386  finally
    242387    Data.Free;
     
    246391constructor TCommTelnet.Create;
    247392begin
    248   FCommandData := TStreamHelper.Create;
     393  FResponses := TListObject.Create;
     394  FCommandData := TBinarySerializer.Create;
     395  FCommandData.List := TListByte.Create;
     396  FCommandData.OwnsList := True;
    249397  TelnetPin := TCommPin.Create;
     398  TelnetPin.OnReceive := TelnetDataReceive;
    250399  RawPin := TCommPin.Create;
     400  RawPin.OnReceive := RawDataReceive;
    251401  Options := TListObject.Create;
     402  Options.OwnsObjects := False;
    252403  Timeout := 2 * OneSecond;
    253404end;
     
    259410  TelnetPin.Free;
    260411  RawPin.Free;
     412  FResponses.Free;
    261413  inherited Destroy;
    262414end;
  • PinConnection/UCommTelnetComPortOption.pas

    r408 r411  
    1919  TTelnetOptionComPort = class(TTelnetOption)
    2020  private
     21    FBaudRate: Cardinal;
     22    FDTR: Boolean;
     23    FRTS: Boolean;
     24    function GetDataBits: TDataBits;
     25    function GetDTR: Boolean;
     26    function GetFlowControl: TFlowControl;
     27    function GetParity: TParity;
     28    function GetRTS: Boolean;
     29    function GetStopBits: TStopBits;
     30    function GetBaudRate: Cardinal;
     31    procedure SetBaudRate(Value: Cardinal);
     32    procedure SetDataBits(AValue: TDataBits);
     33    procedure SetDTR(AValue: Boolean);
     34    procedure SetFlowControl(AValue: TFlowControl);
     35    procedure SetParity(AValue: TParity);
     36    procedure SetRTS(AValue: Boolean);
     37    procedure SetStopBits(AValue: TStopBits);
     38  protected
     39    procedure SetActive(AValue: Boolean); override;
    2140  public
    22     procedure SetBaudRate(Value: Cardinal);
    23     function GetBaudRate: Cardinal;
    2441    constructor Create;
    2542    destructor Destroy; override;
     43    property FlowControl: TFlowControl read GetFlowControl write SetFlowControl;
     44    property DataBits: TDataBits read GetDataBits write SetDataBits;
     45    property StopBits: TStopBits read GetStopBits write SetStopBits;
     46    property Parity: TParity read GetParity write SetParity;
     47    property BaudRate: Cardinal read GetBaudRate write SetBaudRate;
     48    property RTS: Boolean read GetRTS write SetRTS;
     49    property DTR: Boolean read GetDTR write SetDTR;
    2650  end;
    2751
     
    3155{ TTelnetOptionComPort }
    3256
     57function TTelnetOptionComPort.GetDataBits: TDataBits;
     58begin
     59
     60end;
     61
     62function TTelnetOptionComPort.GetDTR: Boolean;
     63begin
     64
     65end;
     66
     67function TTelnetOptionComPort.GetFlowControl: TFlowControl;
     68begin
     69
     70end;
     71
     72function TTelnetOptionComPort.GetParity: TParity;
     73begin
     74
     75end;
     76
     77function TTelnetOptionComPort.GetRTS: Boolean;
     78begin
     79
     80end;
     81
     82function TTelnetOptionComPort.GetStopBits: TStopBits;
     83begin
     84
     85end;
     86
     87procedure TTelnetOptionComPort.SetActive(AValue: Boolean);
     88begin
     89  inherited;
     90  //SetBaudRate(FBaudRate);
     91  //SetDTR(FDTR);
     92  //SetRTS(FRTS);
     93end;
     94
    3395procedure TTelnetOptionComPort.SetBaudRate(Value: Cardinal);
    3496var
    3597  Request: TBinarySerializer;
    3698begin
     99  FBaudRate := Value;
     100  if Telnet.Active then
    37101  try
    38102    Request := TBinarySerializer.Create;
     
    41105    Request.WriteByte(Byte(cpcSetBaudRate));
    42106    Request.WriteCardinal(Value);
    43 //    Telnet.SendSubCommand(tmComPortControlOption, Request, nil);
     107    Telnet.SendSubCommand(tmComPortControlOption, Request.List, nil);
    44108  finally
    45109    Request.Free;
     
    49113function TTelnetOptionComPort.GetBaudRate: Cardinal;
    50114var
    51   Request: TStreamHelper;
    52   Response: TStreamHelper;
    53 begin
    54   try
    55     Request := TStreamHelper.Create;
    56     Response := TStreamHelper.Create;
     115  Request: TBinarySerializer;
     116  Response: TBinarySerializer;
     117begin
     118  if Telnet.Active then
     119  try
     120    Request := TBinarySerializer.Create;
     121    Request.List := TListByte.Create;
     122    Request.OwnsList := True;
     123    Response := TBinarySerializer.Create;
     124    Response.List := TListByte.Create;
     125    Response.OwnsList := True;
    57126    Request.WriteByte(Byte(cpcSetBaudRate));
    58127    Request.WriteCardinal(0);
    59 //    Telnet.SendSubCommand(tmComPortControlOption, Request, Response);
     128    Telnet.SendSubCommand(tmComPortControlOption, Request.List, Response.List);
    60129    Response.Position := 0;
    61130    Result := Response.ReadCardinal;
     
    63132    Response.Free;
    64133    Request.Free;
    65   end;
     134  end else Result := 0;
     135end;
     136
     137procedure TTelnetOptionComPort.SetDataBits(AValue: TDataBits);
     138begin
     139
     140end;
     141
     142procedure TTelnetOptionComPort.SetDTR(AValue: Boolean);
     143var
     144  Request: TBinarySerializer;
     145begin
     146  FDTR := AValue;
     147  if Telnet.Active then
     148  try
     149    Request := TBinarySerializer.Create;
     150    Request.List := TListByte.Create;
     151    Request.OwnsList := True;
     152    Request.WriteByte(Byte(cpcSetControl));
     153    if AValue then Request.WriteByte(8)
     154      else Request.WriteByte(9);
     155    Telnet.SendSubCommand(tmComPortControlOption, Request.List, nil);
     156  finally
     157    Request.Free;
     158  end;
     159end;
     160
     161procedure TTelnetOptionComPort.SetFlowControl(AValue: TFlowControl);
     162var
     163  Request: TBinarySerializer;
     164begin
     165  if Telnet.Active then
     166  try
     167    Request := TBinarySerializer.Create;
     168    Request.List := TListByte.Create;
     169    Request.OwnsList := True;
     170    Request.WriteByte(Byte(cpcSetControl));
     171    case AValue of
     172      fcNone: Request.WriteByte(1);
     173      fcSoftware: Request.WriteByte(2);
     174      fcHardware: Request.WriteByte(3);
     175    end;
     176    Telnet.SendSubCommand(tmComPortControlOption, Request.List, nil);
     177  finally
     178    Request.Free;
     179  end;
     180end;
     181
     182procedure TTelnetOptionComPort.SetParity(AValue: TParity);
     183begin
     184
     185end;
     186
     187procedure TTelnetOptionComPort.SetRTS(AValue: Boolean);
     188var
     189  Request: TBinarySerializer;
     190begin
     191  FRTS := AValue;
     192  if Telnet.Active then
     193  try
     194    Request := TBinarySerializer.Create;
     195    Request.List := TListByte.Create;
     196    Request.OwnsList := True;
     197    Request.WriteByte(Byte(cpcSetControl));
     198    if AValue then Request.WriteByte(11)
     199      else Request.WriteByte(12);
     200    Telnet.SendSubCommand(tmComPortControlOption, Request.List, nil);
     201  finally
     202    Request.Free;
     203  end;
     204end;
     205
     206procedure TTelnetOptionComPort.SetStopBits(AValue: TStopBits);
     207begin
     208
    66209end;
    67210
    68211constructor TTelnetOptionComPort.Create;
    69212begin
     213  Code := tmComPortControlOption;
    70214end;
    71215
Note: See TracChangeset for help on using the changeset viewer.