cnModem与硬件Wave Modem通讯的问题,指令发出去没有反应
Wave Modem装在Com1上,用超级终端测试没有问题,可是用cnModem控件发送指令没有反应呀,为什么?是不是还有参数要修改?
程序的代码如下:
//打开端口
procedure TForm1.btn_2Click(Sender: TObject);
begin
CnModem1.CommName:='Com1';
CnModem1.CommConfig.BaudRate:=9600;
CnModem1.StartComm;
end;
//发送AT指令
procedure TForm1.btn_1Click(Sender: TObject);
begin
CnModem1.WriteATCommand('at');
sleep(300);
// CnModem1.WriteATCommand('AT+Cgmi');
// CnModem1.WriteATCommand('AT+Cmgf=0');
// sleep(300);
// CnModem1.WriteATCommand('AT+CMgL=4');
// sleep(300);
end;
//接收数据
procedure TForm1.CnModem1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
Var
i,LengthTotal: word;
s, tmp: String;
rbuf: Array[0..2047] Of byte;
iPos1, iPos2: integer;
Begin
s := '';
LengthTotal :=BufferLength;
FillChar(rbuf, 2048, #0);
Move(Buffer^, pchar(@rbuf)^, LengthTotal);
For i := 0 To LengthTotal - 1 Do
s := s + chr(rbuf[i]);
mmo_1.Lines.Add(s) ;
mmo_1.Lines.Add('-----------------------------');
end;
//关闭端口
procedure TForm1.btn_3Click(Sender: TObject);
begin
CnModem1.StopComm;
end;
|