• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 
March 29, 2024, 06:15:22 am

News:

SMF - Just Installed!


TIMEOUT ?

Started by MTZOVARAS, June 11, 2009, 06:05:21 am

Previous topic - Next topic

MTZOVARAS

Hi,

i have 3 serial ports with one analyzer on each port and the scenario :

- ask analyzer 1
- get the answer from analyzer 1
- ask analyzer 2
- get the answer from analyzer 2
- ask analyzer 3
- get the answer from analyzer 3

all the previous in a continous loop and i get the answers with data packets.

The problem starts when analyzer 2 is off, so there is no answer.

I want my application to wait for 3 seconds for the answer of analyzer 2

and if there is no answer to continue the loop with analyzer 3 etc

Also i want to have a log when the analyzer did not answer.

My problem is where to set the timeout of 3 seconds, and how to manage the situation.

Thank you,


Minas

Roman Novgorodov

Hello

Your question does not related with nrComm Lib directly.
You need more think. It is ordinary programmer task :-).

For example the following way is possible:

You need three instances (copies) of TnrComm for each serial port.
You need three handlers of OnAfterReceive event.
Use TTimer component for timeouts.
Set TTimer.Enable in true after SendString()
Set TTimer.Enable in false in OnAfterReceive handler
Add log message about timeout error in OnTimer event.
.. and so on.

It's easy. :-)

Roman Novgorodov


DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

MTZOVARAS

Hello,

i was a Turbo Power Asynch Pro user and there was a [timeout] property and [ontimeout] event that i was using for that purpose.

I notice [timeout] property in nrDataProcessor and [OnTimeOut] so i thought it was for the same purpose.

Of course there are other ways to solve that problem outside nrComm.

Thank you,

Minas

Roman Novgorodov

Hello

There is another "synchronous" way.
You can try to use TnrComm.WaitForBytes() method.

But asynchronous OnAfterReceive is more better.

Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.