Board index » delphi » Receive message when serial port characters arrive.

Receive message when serial port characters arrive.

I am using Delphi 2.0 and using CreateFile to open a serial port.
I would like to receive a message whenever a character is received
through the serial port. Is this possible ? Or do I have to use
asynchronous calls to ReadFile ?

Thanks in advance.
Stephen Graham.
s...@ozemail.com.au

 

Re:Receive message when serial port characters arrive.


In article <325067ec.32616...@news.ozemail.com.au>, Stephen Graham
<s...@ozemail.com.au> writes

Quote
>I am using Delphi 2.0 and using CreateFile to open a serial port.
>I would like to receive a message whenever a character is received
>through the serial port. Is this possible ? Or do I have to use
>asynchronous calls to ReadFile ?

>Thanks in advance.
>Stephen Graham.
>s...@ozemail.com.au

You could use a thread process to poll the port in the background. The thread
will gobble cpu cycles though, I havn't found out how to set a priority yet, and
you MUST ensure that you kill the thread when the application terminates or else
the thread will still be there running - parentless in the background.

--
Moebius

Re:Receive message when serial port characters arrive.


In message <n$2RbAAPHTUyE...@mtechsec.demon.co.uk>, Moebius <R...@mtechsec.demon.co.uk> said:

Quote
> You could use a thread process to poll the port in the background. The thread
> will gobble cpu cycles though

Not if you use WaitForSingleObject() or WaitForMultipleObjects(). NEVER EVER use
polling in a multi-tasking environment unless you have a *really* good reason.
(And if you don't know what a really good reason might be, you don't have one!)

-----------------------------------------------------------------------
Steve Rencontre               |  st...@dstrip.demon.co.uk (business)
If it works, it's obsolete.   |  steve...@cix.compulink.co.uk (private)
-----------------------------------------------------------------------

Other Threads