WIFI 模块 串口 调试 助手

来源:互联网 发布:ubuntu 重启vnc服务 编辑:程序博客网 时间:2024/04/30 14:06

本人在调试wifi模块时,用delphi写了个wifi模块调试助手的程序,

串口采用mscomm,

开启mscomm

procedure TForm1.FormCreate(Sender: TObject);

begin
try
   configinifile:=Tinifile.create('config/config.ini');
   mscomm1.CommPort:=configinifile.readinteger('gsmmscomm','commport',2);
   mscomm1.Settings:=configinifile.readString('gsmmscomm','settings','9600,n,8,1');
   mscomm1.PortOpen:=true;
except
 MessageBox(0,'请修改配置文件config.ini的端口号','串口端口号设置错误或者不存在此端口号!',MB_OK);
end;
   edit2.Text:=inttostr(mscomm1.CommPort);
end;

mscomm接收事件处理程序:

procedure TForm1.MSComm1Comm(Sender: TObject);
var
  inputCount:integer;
  tmpStr:string;
  tmpArray:array of byte;
  i:integer;
begin
  tmpStr:='';
   case mscomm1.CommEvent of
   comEvReceive:
     begin
      tmpStr:='';
      inputCount:=mscomm1.InBufferCount;
    //  tmpReadCount:=inputCount;
      setLength(tmpArray,inputcount);
      tmpArray:=mscomm1.input;
    //  analizeData(tmpArray );
  //-------------------------------------------------//
       for i:=0 to inputCount -1 do
       begin
        if blnHex then
         tmpStr:=tmpstr +' '+intTohex(tmpArray[i],2)
        else
         tmpStr:=tmpStr+chr(tmpArray[i]);
       if (tmpArray[i-1]=13)and(tmpArray[i]=10) then
        begin
         memInfo.Text:=memInfo.Text+tmpStr+#13#10;
         memInfo.SelStart:=length(memInfo.Text);
         tmpStr:='';
        end;
       end;//end for
       memInfo.Text:=memInfo.Text+tmpstr;
       memInfo.SelStart:=length(memInfo.Text);
     //  memInfo.ScrollBars.
   //   sendmessage(memInfo.Handle,WM_VSCROLL,SB_BOTTOM,0);
      //滚动条下滑
       memInfo.SelStart:=   getTextlen;
       memInfo.SelLength:=   Length(memInfo.text);
 //-----------------------------------------------------//
     end;
   else;
   end; //end case;
end;

 

模块和程序效果图如下:

模块A模块B

wifi at命令调试助手