A
acbcwy
Unregistered / Unconfirmed
GUEST, unregistred user!
目前正在编写利用AnyData CDMA Modem 发送接受短消息的一个组件,如有解答问题者,可
获得最终原程序一份.
我想在程序中动态创建Spcomm控件,控制Modem, 程序如下,但是发出去指令,没有回应?
请各位大虾指点。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Spcomm, Db;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
procedure DoOnReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
AComm:TComm;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
AComm:=TComm.Create(Form1);
AComm.CommName:='COM1';
AComm.BaudRate := 9600;
AComm.OnReceiveData:=DoOnReceiveData;
AComm.StartComm;
end;
procedure TForm1.DoOnReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
Str1:String;
Begin
Str1:=Pchar(Buffer);
Memo1.Lines.Append(Str1);
End;
procedure TForm1.Button2Click(Sender: TObject);
var
Str1:String;
begin
Str1:='AT'+#$0D;
AComm.WriteCommData(pchar(str1),Length(Str1));
end;
end.
获得最终原程序一份.
我想在程序中动态创建Spcomm控件,控制Modem, 程序如下,但是发出去指令,没有回应?
请各位大虾指点。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Spcomm, Db;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
procedure DoOnReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
AComm:TComm;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
AComm:=TComm.Create(Form1);
AComm.CommName:='COM1';
AComm.BaudRate := 9600;
AComm.OnReceiveData:=DoOnReceiveData;
AComm.StartComm;
end;
procedure TForm1.DoOnReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
Str1:String;
Begin
Str1:=Pchar(Buffer);
Memo1.Lines.Append(Str1);
End;
procedure TForm1.Button2Click(Sender: TObject);
var
Str1:String;
begin
Str1:='AT'+#$0D;
AComm.WriteCommData(pchar(str1),Length(Str1));
end;
end.