Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7181761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:37:29+00:00 2026-05-28T17:37:29+00:00

I’m working on a small component for writing and reading AT Commands using an

  • 0

I’m working on a small component for writing and reading AT Commands using an old Sony Ericsson phone.
Sending and writing to/from the phone is no problem at all, however I would like to be able to pause my SendATCmd function and wait for the COM Port component to notify me with a Notification Event, and then resume the SendATCmd function again.

Scenario: I want to get the count of SMS messages in the phone.
Normally I’d just tell the phone: Hey, how many SMS messages do you have?
and the phone would reply in the notification event.
Thats all good.

But what I really want to do is something like

if SendATCmd('CountSMS')>0 then
  for 0 to SMSCount do
    AddSMSToList;

The code for SendATCmd looks like this:

function TSE_Z1010.SendATCmd(Cmd: string): TATResult;
begin
  fCOMPort.PutString(Cmd); //Sending AT command

  //Here is where I would like to pause this function
  //wait for the fCOMPort to notify me when data is available
  //and then resume this function again.

  result:=fTMPATResult;

end;

I’ve tried using a while-loop, pause, etc etc, but nothing’s worked except for one thing, and that’s when I put a ShowMessage where the pause should be.
I don’t know how ShowMessage works internally but it seems that it doesn’t halt the program like while-loop and pause do.

====================

Fixed it.

All I had to do was to add Forms in the uses clause, and then I added while fTMPATResult.Full=false do Application.ProcessMessages; in the part where I wanted to pause the procedure.

“fTMPATResult” is the variable where the incoming COM Port data is stored, globally within the component.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:37:31+00:00Added an answer on May 28, 2026 at 5:37 pm

    While AsyncPro does have some solutions for this (ontriggerdata), they are event based and make code difficult to read/understand.

    here is SendAndWaitForResponse with AsyncPro (like Remy suggested):

    TForm1 = class(TForm)
     ...
    private
        IOEvent           : THandle; // used for IO events
        IORx              : string;
        Comport           : TapdComport;
    ...
    
    
    procedure TForm1.ComportTriggerAvail(CP: TObject; Count: Word);
    
    var i       : integer;
    
    begin
     for i:=1 to Count do
      IORx:=IORx+Comport.GetChar;
     SetEvent(IOEvent);
    end;
    
    function TForm1.SerialSAWR(tx : string; TimeOut : integer) : boolean;
    begin
     Result := False;
     try
      IORx := ''; // your global var
      ResetEvent(IOEvent);
      Comport.PutString(tx);
      Result := WaitForSingleObject(IOEvent, TimeOut) = WAIT_OBJECT_0;
     except
      on E : Exception do
       // dosomething with exception
     end;
    end;
    
    // constructor part
    IOEvent := CreateEvent(nil, True, False, nil);
    // destructor part
     if IOEvent <> 0 then
      CloseHandle(IOEvent);
    

    Best solution is to create a thread with the comport so your GUI won’t be blocked.
    I have several applications in production with Asyncpro this way and it works like a charm…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.