Changeset 409 for PinConnection/USerialPort.pas
- Timestamp:
- Aug 14, 2012, 11:55:28 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/USerialPort.pas
r407 r409 37 37 FDTR: Boolean; 38 38 FActive: Boolean; 39 FBaudRate: TBaudRate;39 FBaudRate: Integer; 40 40 FDataBits: TDataBits; 41 41 FFlowControl: TFlowControl; … … 46 46 FReceiveThread: TSerialPortReceiveThread; 47 47 FReceiveBuffer: TListByte; 48 function GetBaudRateNumeric: Integer;49 48 function GetName: string; 50 procedure SetBaudRate(const AValue: TBaudRate); 51 procedure SetBaudRateNumeric(const AValue: Integer); 49 procedure SetBaudRate(const AValue: Integer); 52 50 procedure SetDataBits(const AValue: TDataBits); 53 51 procedure SetDTR(const AValue: Boolean); … … 66 64 property StopBits: TStopBits read FStopBits write SetStopBits; 67 65 property Parity: TParity read FParity write SetParity; 68 property BaudRate: TBaudRateread FBaudRate write SetBaudRate;66 property BaudRate: Integer read FBaudRate write SetBaudRate; 69 67 property Active: Boolean read FActive write SetActive; 70 68 property RTS: Boolean read FRTS write SetRTS; … … 72 70 property ReceiveBuffer: TListByte read FReceiveBuffer; 73 71 74 property BaudRateNumeric: Integer read GetBaudRateNumeric write SetBaudRateNumeric;75 72 property OnReceiveData: TReceiveDataEvent read FOnReceiveData write FOnReceiveData; 76 73 procedure LoadAvailableToStrings(Strings: TStrings; Check: Boolean = False); … … 215 212 inherited Create; 216 213 FReceiveBuffer := TListByte.Create; 217 FBaudRate := br9600;214 FBaudRate := 9600; 218 215 FName := 'COM1'; 219 216 FDataBits := 8; … … 248 245 end; 249 246 250 procedure TSerialPort.SetBaudRate(const AValue: TBaudRate);247 procedure TSerialPort.SetBaudRate(const AValue: Integer); 251 248 begin 252 249 FBaudRate := AValue; 253 250 if FActive then begin 254 251 GetCommState; 255 DCB.BaudRate := BaudRateNumeric; 256 SetCommState; 257 end; 258 end; 259 260 function TSerialPort.GetBaudRateNumeric: Integer; 261 begin 262 Result := BaudRateNumericTable[FBaudRate]; 252 DCB.BaudRate := AValue; 253 SetCommState; 254 end; 263 255 end; 264 256 … … 266 258 begin 267 259 Result := FName; 268 end;269 270 procedure TSerialPort.SetBaudRateNumeric(const AValue: Integer);271 begin272 case AValue of273 110: BaudRate := br110;274 300: BaudRate := br300;275 600: BaudRate := br600;276 1200: BaudRate := br1200;277 2400: BaudRate := br2400;278 4800: BaudRate := br4800;279 9600: BaudRate := br9600;280 14400: BaudRate := br14400;281 19200: BaudRate := br19200;282 38400: BaudRate := br38400;283 56000: BaudRate := br56000;284 57600: BaudRate := br57600;285 115200: BaudRate := br115200;286 128000: BaudRate := br128000;287 256000: BaudRate := br256000;288 else raise Exception.CreateFmt(SWrongNumericBaudRate, [AValue]);289 end;290 260 end; 291 261
Note:
See TracChangeset
for help on using the changeset viewer.