unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Buttons, StdCtrls, SdpoSerial; type { TForm1 } TForm1 = class(TForm) BitBtn_close: TBitBtn; Button_connect: TButton; Button_disconnect: TButton; Button_send: TButton; ComboBox_flowcontrol: TComboBox; ComboBox_databits: TComboBox; ComboBox_stopbits: TComboBox; ComboBox_parite: TComboBox; ComboBox_port: TComboBox; ComboBox_baudrate: TComboBox; Edit1: TEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Memo_terminal: TMemo; SdpoSerial1: TSdpoSerial; procedure Button_connectClick(Sender: TObject); procedure Button_disconnectClick(Sender: TObject); procedure Button_sendClick(Sender: TObject); procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure FormCreate(Sender: TObject); procedure SdpoSerial1RxData(Sender: TObject); private { private declarations } public { public declarations } end; var Form1: TForm1; implementation { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin SdpoSerial1.Active:=False; end; procedure TForm1.SdpoSerial1RxData(Sender: TObject); var rec:string; begin rec:=SdpoSerial1.ReadData; Memo_terminal.Append(rec); end; procedure TForm1.Button_connectClick(Sender: TObject); begin Memo_terminal.Clear; SdpoSerial1.Device:=ComboBox_port.text; SdpoSerial1.BaudRate:=TBaudrate(ComboBox_baudrate.ItemIndex); SdpoSerial1.DataBits:=TDataBits(ComboBox_databits.ItemIndex); SdpoSerial1.FlowControl:=TFlowControl(ComboBox_flowcontrol.ItemIndex); SdpoSerial1.Parity:=TParity(ComboBox_parite.ItemIndex); SdpoSerial1.StopBits:=TStopBits(ComboBox_stopbits.ItemIndex); SdpoSerial1.Active:=True; end; procedure TForm1.Button_disconnectClick(Sender: TObject); begin SdpoSerial1.Active:=false; end; procedure TForm1.Button_sendClick(Sender: TObject); begin SdpoSerial1.WriteData(Edit1.text); end; procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction); begin SdpoSerial1.Active:=false; end; initialization {$I unit1.lrs} end.