Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Process messages

Status
Not open for further replies.

Tremorblue

Programmer
Apr 30, 2004
56
GB
I am using a component that talks via the serial port

I send a message then sit in a loop waiting for a response.
This is convenient as one function can fire a message and wait for the response. It doesnt work as the component does not get time to process incoming data. So I call Application->Processmessages(); the component then gets time to get the response.

The down side of this command is that instead of my application being locked for a second or two whilst data comes in, the users can click buttons and fire off other serial events leading to all sorts of reentrant problems.

I thought of bringing up a little modal busy form whilst the response was coming in to stop people pressing anything else. But when the form was up the stuff in the background locked up.

Any ideas appreciated.
/Regards
TBlue.
 
Had a similar problem. I started using TurboPower's AsyncPro ( It has a component (TAdpDataPacket) that waits in the background until the serial port has data, then fires a trigger that your program can catch and process the serial data.

I suppose you can create one yourself. It would require you to create a thread that looks at the serial port then send a message to your main program when there is data.

James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
I'm too using TurboPower's component and it works like a charm! In my case one message are terminated with ETX (ASCII 03) which made it possible to make a trigger on that char.

Alas: when a complete package has arrived it fires that event, the eventhandler (my thing) decodes the package and it works fast!

It can trigger om strings (i do that, a very short string), number of bytes and so on.

Highly recommendable.

Totte
Keep making it perfect and it will end up broken.
 
disable the buttons before
and then enable them after

yeah I know, it is not one of those
cutesy 3rd party jobs, so never mind.

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top