05-11-2010 06:52 AM
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 ?
Solved! Go to Solution.
05-11-2010 07:00 AM
05-11-2010 07:42 AM - edited 05-11-2010 07:47 AM
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 ?
05-12-2010 10:57 AM
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.
05-13-2010 01:25 AM
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.