Jump to content

MD RASEL

Members
  • Content Count

    2
  • Joined

  • Last visited

Posts posted by MD RASEL


  1. 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.


  2. 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.

×