LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi Thread Timers

Solved!
Go to solution

Hi All

 

I am working on a project which request and recieves values from a modbus tcp through a ethernet connection.

Currently i am using a timer to check for timeouts and the same timer to re-connect the connection and send the next request if there is no timeout.

The problem is that when one of the  connections timeout the other connection read slower.

 

How can i create multithreads with each connection having its own timer to deal with the timeouts and requests ?

 

Help share your knowlegde
0 Kudos
Message 1 of 5
(4,244 Views)
The easist approach involves the use of asynchronous timers, toolslib\toolbox\asynctmr.fp
Message 2 of 5
(4,242 Views)

Thanks.

It works initially.

But when i get a timeout and try to reconnect in the timer and send a request i get a write failed error.

 

Why could this be ?

Message Edited by Shako on 05-11-2010 02:47 PM
Help share your knowlegde
0 Kudos
Message 3 of 5
(4,237 Views)

Shako,

 

I'm not sure why you're running into that error, if you still wanted to use multiple threads, have you seen the simple.cws example that ships with CVI? You can get to it by searching for thread in the example finder, and should be a good place to get started, though getting the async timer to work would be a more elegant solution. 

Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 4 of 5
(4,192 Views)
Solution
Accepted by topic author Shako

I found a solution.

 

The problem i was having was that i had to have a delay for about 0.5 second in order to reconnect.

Then i found another way to connect and send a request but i forgot to remove the delay.

That was why i wanted to use the async timer and that was why i was getting that error.

 

When i removed the delay every thing is working has it should and it is all been ran in one timer which saves a lot of confusion in the code.

 

 

Thanks for all your help.

Help share your knowlegde
0 Kudos
Message 5 of 5
(4,173 Views)