Ignore:
Timestamp:
Aug 14, 2012, 11:55:28 AM (12 years ago)
Author:
chronos
Message:
  • Modified: Class TSerialPort in PinConnection package now use only numeric baud rate instead of static list of possible rates.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/USerialPort.pas

    r407 r409  
    3737    FDTR: Boolean;
    3838    FActive: Boolean;
    39     FBaudRate: TBaudRate;
     39    FBaudRate: Integer;
    4040    FDataBits: TDataBits;
    4141    FFlowControl: TFlowControl;
     
    4646    FReceiveThread: TSerialPortReceiveThread;
    4747    FReceiveBuffer: TListByte;
    48     function GetBaudRateNumeric: Integer;
    4948    function GetName: string;
    50     procedure SetBaudRate(const AValue: TBaudRate);
    51     procedure SetBaudRateNumeric(const AValue: Integer);
     49    procedure SetBaudRate(const AValue: Integer);
    5250    procedure SetDataBits(const AValue: TDataBits);
    5351    procedure SetDTR(const AValue: Boolean);
     
    6664    property StopBits: TStopBits read FStopBits write SetStopBits;
    6765    property Parity: TParity read FParity write SetParity;
    68     property BaudRate: TBaudRate read FBaudRate write SetBaudRate;
     66    property BaudRate: Integer read FBaudRate write SetBaudRate;
    6967    property Active: Boolean read FActive write SetActive;
    7068    property RTS: Boolean read FRTS write SetRTS;
     
    7270    property ReceiveBuffer: TListByte read FReceiveBuffer;
    7371
    74     property BaudRateNumeric: Integer read GetBaudRateNumeric write SetBaudRateNumeric;
    7572    property OnReceiveData: TReceiveDataEvent read FOnReceiveData write FOnReceiveData;
    7673    procedure LoadAvailableToStrings(Strings: TStrings; Check: Boolean = False);
     
    215212  inherited Create;
    216213  FReceiveBuffer := TListByte.Create;
    217   FBaudRate := br9600;
     214  FBaudRate := 9600;
    218215  FName := 'COM1';
    219216  FDataBits := 8;
     
    248245end;
    249246
    250 procedure TSerialPort.SetBaudRate(const AValue: TBaudRate);
     247procedure TSerialPort.SetBaudRate(const AValue: Integer);
    251248begin
    252249  FBaudRate := AValue;
    253250  if FActive then begin
    254251    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;
    263255end;
    264256
     
    266258begin
    267259  Result := FName;
    268 end;
    269 
    270 procedure TSerialPort.SetBaudRateNumeric(const AValue: Integer);
    271 begin
    272   case AValue of
    273     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;
    290260end;
    291261
Note: See TracChangeset for help on using the changeset viewer.