Ignore:
Timestamp:
Aug 16, 2012, 9:54:23 AM (12 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.