LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP communication interrupted when my device turns OFF and then powered up again

Hello Dushy_11,

not elegant but working method, store the reference in a global variable and all SubVI´s use it. After the reconnect replace the reference in the global variable so all get the new one.

Better, do not transfer the reference, only the results so only in one VI write and read to TCP is done and from this VI the data will be transfered.

best regards
Alexander
0 Kudos
Message 11 of 16
(1,035 Views)

You have some basic logic problems.

Let's take a look at your first loop:

 

Connect.PNG

 

I convert that into pseudocode:

REPEAT

    OPEN CONNECTION (192.168.11.2:5000, Timeout = 1000)

    If Error, compose Fault Description.

    STOP = not (not (Error)) or Exit Button

until STOP

so... as long as the connection succeeds, you keep trying, but as soon as it fails you quit ???

Why try to connect again if it succeeds?

 

Also check your following logic - it looks like you ignore things (green case) if you succeed, and do stuff if you fail.

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 12 of 16
(1,030 Views)

Hi Steve

I am so sorry that i forgot to remove one "not" function. Its only one "not"  function in the running code.

Actually was trying something else so put one extra "not" function and afterwards forgot to remove it while posting the code here.

 

 

0 Kudos
Message 13 of 16
(1,017 Views)

Hi

Thanks for your input. I will surely implement Global variable in my code as you suggested.

But i have few queries regarding the same.

1. When i am opening the Sub VI from my main VI, i am closing the Main VI through INVOKE NODE and again opening the Main VI when clicking back from the Sub VI. So in that case, if i communicate through TCP/IP in Main VI only, will i be able to send and recieve data in my Sub VI. I am sending & recieving different data based on my commands in Main VI & My Sub VIs

 

0 Kudos
Message 14 of 16
(1,016 Views)

Hello Dushy_11,

 

yes, the global variable should always be accessable, but be carefull that no racecondition happen, because you do not know exactly, when the variable was written or read. A queue like you use for the commands, could be helpfull to prevent you from a racecondition.

best regards
Alexander
0 Kudos
Message 15 of 16
(999 Views)

Hi Alexander

 

Thanks for your precious suggestion

I am not able to implement the same on my code as i am out of station officially.

Once i get back and implement the same, i will give you the feedback.

 

best regards

Dushyant

0 Kudos
Message 16 of 16
(980 Views)