Jump to content
MD RASEL

How To Send AT Command Model Port

Recommended Posts

im Try This Link https://blogs.embarcadero.com/powerful-serial-communication-component-for-delphi-and-c-builder-on-windows/  

See My Full Project I Need Solution Please Help me

 

unit comport;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Buttons, Vcl.StdCtrls, Vcl.ComCtrls,CPort;

 

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    SpeedButton1: TSpeedButton;
    ComPort: TComPort;
    procedure SpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    HaveAnswer  : Boolean;
      function WaitForAnswer(aInterval:integer):Boolean;
      function SendCommand(aCommand:string; waitInterval:cardinal):Boolean;
  end;

 

var
  Form1: TForm1;

 

implementation

{$R *.dfm}


function TForm1.WaitForAnswer(aInterval:integer):Boolean;
var
  aTick : cardinal;
begin
  aTick:=TThread.GetTickCount;
  while TThread.GetTickCount-aTick<aInterval do
  begin
    if HaveAnswer then Break;
    TThread.Sleep(1);
    Application.ProcessMessages;
  end;
  Result:=HaveAnswer;
end;

function TForm1.SendCommand(aCommand:string; waitInterval:cardinal):Boolean;
begin
  Result:=False;
  RichEdit1.Lines.Add('Samsung Reading Info OK');
  HaveAnswer:=False;
  try
     ComPort.Write(aCommand+#13#10,TEncoding.ANSI);                              ///    This Code Run Project But AT Command Not Working        ComPort.WriteStr(aCommand+#13#10);
    RichEdit1.Lines.Add(aCommand+' Unlock Data Send');
    Result:=WaitForAnswer(waitInterval);
    if not Result then RichEdit1.Lines.Add('Samsung Device Not Found');
  except
    on E:Exception do RichEdit1.Lines.Add(E.Message);
  end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
   HaveAnswer:=False;
    if SendCommand('FRP',5000)
    then SendCommand('AT+DEVCONINFO',10000);
end;

end.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×