Author Topic: TIMEOUT ?  (Read 2115 times)

MTZOVARAS

  • Newbie
  • *
  • Posts: 5
    • View Profile
TIMEOUT ?
« on: June 11, 2009, 09:05:21 am »
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

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: TIMEOUT ?
« Reply #1 on: June 11, 2009, 10:42:34 am »
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

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: TIMEOUT ?
« Reply #2 on: June 13, 2009, 10:34:08 am »
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

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: TIMEOUT ?
« Reply #3 on: June 13, 2009, 01:26:16 pm »
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.