Changeset 411 for PinConnection/UCommTelnetComPortOption.pas
- Timestamp:
- Aug 16, 2012, 9:54:23 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/UCommTelnetComPortOption.pas
r408 r411 19 19 TTelnetOptionComPort = class(TTelnetOption) 20 20 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; 21 40 public 22 procedure SetBaudRate(Value: Cardinal);23 function GetBaudRate: Cardinal;24 41 constructor Create; 25 42 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; 26 50 end; 27 51 … … 31 55 { TTelnetOptionComPort } 32 56 57 function TTelnetOptionComPort.GetDataBits: TDataBits; 58 begin 59 60 end; 61 62 function TTelnetOptionComPort.GetDTR: Boolean; 63 begin 64 65 end; 66 67 function TTelnetOptionComPort.GetFlowControl: TFlowControl; 68 begin 69 70 end; 71 72 function TTelnetOptionComPort.GetParity: TParity; 73 begin 74 75 end; 76 77 function TTelnetOptionComPort.GetRTS: Boolean; 78 begin 79 80 end; 81 82 function TTelnetOptionComPort.GetStopBits: TStopBits; 83 begin 84 85 end; 86 87 procedure TTelnetOptionComPort.SetActive(AValue: Boolean); 88 begin 89 inherited; 90 //SetBaudRate(FBaudRate); 91 //SetDTR(FDTR); 92 //SetRTS(FRTS); 93 end; 94 33 95 procedure TTelnetOptionComPort.SetBaudRate(Value: Cardinal); 34 96 var 35 97 Request: TBinarySerializer; 36 98 begin 99 FBaudRate := Value; 100 if Telnet.Active then 37 101 try 38 102 Request := TBinarySerializer.Create; … … 41 105 Request.WriteByte(Byte(cpcSetBaudRate)); 42 106 Request.WriteCardinal(Value); 43 // Telnet.SendSubCommand(tmComPortControlOption, Request, nil);107 Telnet.SendSubCommand(tmComPortControlOption, Request.List, nil); 44 108 finally 45 109 Request.Free; … … 49 113 function TTelnetOptionComPort.GetBaudRate: Cardinal; 50 114 var 51 Request: TStreamHelper; 52 Response: TStreamHelper; 53 begin 54 try 55 Request := TStreamHelper.Create; 56 Response := TStreamHelper.Create; 115 Request: TBinarySerializer; 116 Response: TBinarySerializer; 117 begin 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; 57 126 Request.WriteByte(Byte(cpcSetBaudRate)); 58 127 Request.WriteCardinal(0); 59 // Telnet.SendSubCommand(tmComPortControlOption, Request, Response);128 Telnet.SendSubCommand(tmComPortControlOption, Request.List, Response.List); 60 129 Response.Position := 0; 61 130 Result := Response.ReadCardinal; … … 63 132 Response.Free; 64 133 Request.Free; 65 end; 134 end else Result := 0; 135 end; 136 137 procedure TTelnetOptionComPort.SetDataBits(AValue: TDataBits); 138 begin 139 140 end; 141 142 procedure TTelnetOptionComPort.SetDTR(AValue: Boolean); 143 var 144 Request: TBinarySerializer; 145 begin 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; 159 end; 160 161 procedure TTelnetOptionComPort.SetFlowControl(AValue: TFlowControl); 162 var 163 Request: TBinarySerializer; 164 begin 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; 180 end; 181 182 procedure TTelnetOptionComPort.SetParity(AValue: TParity); 183 begin 184 185 end; 186 187 procedure TTelnetOptionComPort.SetRTS(AValue: Boolean); 188 var 189 Request: TBinarySerializer; 190 begin 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; 204 end; 205 206 procedure TTelnetOptionComPort.SetStopBits(AValue: TStopBits); 207 begin 208 66 209 end; 67 210 68 211 constructor TTelnetOptionComPort.Create; 69 212 begin 213 Code := tmComPortControlOption; 70 214 end; 71 215
Note:
See TracChangeset
for help on using the changeset viewer.