S
seeme0526
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是部分代码,可是我接受不到数据,请指教!
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
s: string;
begin
SetLength(S, BufferLength);
Move(Buffer^, PChar(S)^, BufferLength);
dxEdit1.text:=copy(s,7,2)+'.'+copy(s,9,3);
dxEdit2.Text:=S;
end;
procedure TForm1.XP_Button1Click(Sender: TObject);
begin
Comm1.StartComm;
end;
procedure TForm1.XP_Button2Click(Sender: TObject);
begin
Comm1.StopComm;
end;
procedure TForm1.ED_ComChange(Sender: TObject);
begin
Comm1.CommName:=ED_Com.Text;
end;
procedure TForm1.ED_BTLChange(Sender: TObject);
begin
Comm1.BaudRate:=strtoint(ED_BTL.Text);
end;
procedure TForm1.ED_SJWChange(Sender: TObject);
begin
case strtoint(ed_sjw.text) of
5:Comm1.ByteSize:=_5;
6:Comm1.ByteSize:=_6;
7:Comm1.ByteSize:=_7;
8:Comm1.ByteSize:=_8;
end;
end;
procedure TForm1.ED_TZWChange(Sender: TObject);
begin
if ED_TZW.Text='1' then Comm1.StopBits:=_1;
if ED_TZW.Text='1.5' then Comm1.StopBits:=_1_5;
if ED_TZW.Text='2' then Comm1.StopBits:=_2;
end;
end.
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
s: string;
begin
SetLength(S, BufferLength);
Move(Buffer^, PChar(S)^, BufferLength);
dxEdit1.text:=copy(s,7,2)+'.'+copy(s,9,3);
dxEdit2.Text:=S;
end;
procedure TForm1.XP_Button1Click(Sender: TObject);
begin
Comm1.StartComm;
end;
procedure TForm1.XP_Button2Click(Sender: TObject);
begin
Comm1.StopComm;
end;
procedure TForm1.ED_ComChange(Sender: TObject);
begin
Comm1.CommName:=ED_Com.Text;
end;
procedure TForm1.ED_BTLChange(Sender: TObject);
begin
Comm1.BaudRate:=strtoint(ED_BTL.Text);
end;
procedure TForm1.ED_SJWChange(Sender: TObject);
begin
case strtoint(ed_sjw.text) of
5:Comm1.ByteSize:=_5;
6:Comm1.ByteSize:=_6;
7:Comm1.ByteSize:=_7;
8:Comm1.ByteSize:=_8;
end;
end;
procedure TForm1.ED_TZWChange(Sender: TObject);
begin
if ED_TZW.Text='1' then Comm1.StopBits:=_1;
if ED_TZW.Text='1.5' then Comm1.StopBits:=_1_5;
if ED_TZW.Text='2' then Comm1.StopBits:=_2;
end;
end.