关于串口通讯
1.我使用来自[ Kaersoft 卡尔软件]的一个串口通讯控制器,可以成功的向一个AD模块发送命令,然后接收数据.
但没有这个软件所使用的一个控件[TApdComPort],不知道那位哥哥可以给一个.
2.我使用SPCOMM组件的时候,不知道出现了什么问题,希望各位大侠帮忙解决.
问题:
我可以成功的打开串口,也可以写命令字进去,但是读不到数据.简易源代码如下:
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
S: string;
//问题主要在这里...这个接收数据的事件总是不执行
begin
inc(i);
Label1.Caption := IntToStr(i);
showmessage('receivedata');
SetLength(S, BufferLength);
Move(Buffer^, PChar(S)^, BufferLength);
Memo1.Lines.Add(S);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Comm1.StopComm;
Comm1.CommName := 'COM1';//打开串口..串口的其它配置信息在组件的属性栏已经设置
Comm1.StartComm;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Comm1.StopComm;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//writecommdata执行后,可以返回true.
if Comm1.WriteCommData(pchar(Edit1.Text),length(Edit1.Text)) then
showmessage('true')
else showmessage('false');
end;
希望各位大侠看看,我是一个串口通讯的初学者,不知道如何接收数据..