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 9002063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:31:12+00:00 2026-06-16T00:31:12+00:00

After reading this very interesting topic on stackoverflow –> How to wait for COM

  • 0

After reading this very interesting topic on stackoverflow –> How to wait for COM port receive event before sending more data in a loop

I’ve ran into many problems and i’ve tried many solutions … nothing work well unfortunately !

Many serial port libraries are event-driven and i’m having a hard time understanding them.

I’ve tried with Asyncpro, Synaser and TComport.

Is it possible to have a function like this:

SerialSendandReply(tx string here,timeout) return rx string and if timeout send a error string

Response from the device are withing milliseconds a blocking way to do it would be better?

Like this:

Dosomething here
showmessage(SerialSendandReply('test',100 )); //100 ms timeout
dosomething else

With this code

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);

Then i’ve tried to call this function :

if SerialSAWR('test'; 5000) then showmessage(IORx);

Sending is working great but doesn’t return anything in the string.

Any advices?

Thank you very much!

Regards,
Laurent

  • 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-06-16T00:31:13+00:00Added an answer on June 16, 2026 at 12:31 am

    I switched for nrComm Lib (v9.31)… very simple of use and well supported.

    The only drawback is that isn’t free and open source … but it’s worth it !

    It’s also thread-safe which is good too :).

    Thank you very much everyone for the replies!

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

Sidebar

Related Questions

after reading this very interesting thread on duplicate removal , i ended with this
After reading this article I don't have a clear answer: http://palizine.plynt.com/issues/2010Oct/bypass-xss-filters/ Will browsers interpret
After reading this article on thedailywtf.com, I'm not sure that I really got the
After reading this: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-to-use-it I came to the conclusion that it is not valid
After reading this post on Stackoverflow Google plus popup box when hovering over thumbnail?
I've been wondering about this for a while after reading through an interesting article
I was reading this very interesting article for implementing async style loading of js
This is probably a very basic question but after reading documentation I still can't
After reading this very informative (albeit somewhat argumentative) question I would like to know
After reading this question, I need to clear up some things. IQueryable<Customer> custs =

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.