初学者做毕设求注释
这是一个有关串口的程序请高手注释实现部分中的过程中的程序,刚学没多久,要做毕设可是看不懂unit comm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SUIButton, StdCtrls, SUIComboBox, Grids, SUIGrid, SPComm, Inifiles;
type
TfrmComm = class(TForm)
Comm1: TComm;
GroupBox1: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
suiComboBox1: TsuiComboBox;
suiComboBox2: TsuiComboBox;
suiComboBox3: TsuiComboBox;
suiButton1: TsuiButton;
procedure suiButton1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Comm1ReceiveData(Sender: TObject; Buffer: PChar;
BufferLength: Word);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmComm: TfrmComm;
implementation
uses main, DealWithReceiveData, pubvar;
{$R *.dfm}
procedure TfrmComm.suiButton1Click(Sender: TObject);
var
dms_ini:TiniFile;
CommBaud, CommName :string;
CommParity : byte;
begin
dms_ini:=TiniFile.Create(GetCurrentDir()+'\config.ini');
with dms_ini do
begin
Writestring('Comm','CommName',suiComboBox1.Text);
Writestring('Comm','CommBaud',suiComboBox2.Text);
WriteInteger('Comm','CommParity',suiComboBox3.ItemIndex);
end;
dms_ini.Free;
frmMenu.ReadConfig;
close;
end;
procedure TfrmComm.FormShow(Sender: TObject);
var
dms_ini:TiniFile;
CommBaud, CommName :string;
CommParity : byte;
begin
dms_ini:=TiniFile.Create(GetCurrentDir()+'\config.ini');
with dms_ini do
begin
CommName:=trim(readstring('Comm','CommName','1'));
CommBaud:=trim(readstring('COMM','CommBaud','9600'));
CommParity:=readInteger('COMM','CommParity',0);
end;
dms_ini.Free;
suiComboBox1.Text := CommName ;
suiComboBox2.Text := CommBaud ;
suiComboBox3.ItemIndex := CommParity ;
end;
procedure (Sender: TObject; Buffer: PChar;
BufferLength: Word);
var
i : integer;
RxBufTemp : array [0..1000] of byte;
tempstr : string;
begin
for i:=0 to bufferlength-1 do
begin
RxBufTemp[i]:=ord(Buffer[i]); //求字符Buffer的编号
tempstr:=tempstr+inttohex(ord(RxBufTemp[i]),2)+' ';
end;
frmMenu.RecordData('Rx : '+tempstr);
if checkData(RxBufTemp, BufferLength, SysInfo) =1 then
begin
frmMenu.ResetTimer;
DealWithData(SysInfo);
end;
end;
end.