LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous TCP Transfer

I guess the problem is I don't know how to execute event structures correctly.  I understand the problems I am encountering and I know the solution to them, but I do not know how to execute them.  I think where my execution is failing me, is that I don't understand how to make the signals only be sent once, while making it so the waiting VI is constantly listening for the signal.  I am not very experienced with LabVIEW, so if someone can guide me to examples of the items in this thread then I can actually see how the code would execute this.

0 Kudos
Message 21 of 33
(1,419 Views)

Make a loop that does nothing but handle the TCP/IP communications.  It can run in parallel with the main GUI loop.  Then you are constantly listening.  You can use a queue to command it to do things such as connect, send a message, disconnect, stop, etc.  Look up Queued Message Handler for a little more information on that.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 22 of 33
(1,414 Views)

I don't think I understand the queues, dynamics event structures, etc. well enough from the suggestions above.  I understand the problem and how to fix it, but I can't seem to get any of the suggested things to work.  All that I want is if you have VI's A and B where the only thing is a Boolean in each, how can I click either of the Boolean's and the other VI will recognize that it has been pressed without entering the race condition. 

 

I understand that there will be a race condition and that most suggestions involve sending the signal only every time that the buttons are pressed, but however I keep trying to code this doesn't work.  Another suggestion I keep getting is to request the information rather than wait for it, but I do not know how to execute this in the code, so if someone can show me how they would do that, I think it would help the most.

 

Thanks!

0 Kudos
Message 23 of 33
(1,398 Views)

I have been trying to execute this but cannot seem to get it to work.  I have tried to have event structures and queues and other stuff, but nothing seems to work properly.  The errors I keep running into are that when I send the signal only when the boolean is changed, now I have to wait for the next signal to come in and that could be anywhere from 1 second to 10 minutes.  And I don't know how to make the VI remain in a state which will wait for the next signal to come in.

 

Thanks!

0 Kudos
Message 24 of 33
(1,397 Views)

Aha!  I see that you have an error in your code.  I'd tell you where it is, but my Crystal Ball is in the shop, so I can't get it to show me your VI -- to get useful help, attach your VI (or, better, compress the folder holding your Project and attach the resulting .zip file).  We need to see (and understand) what you are doing wrong in order to explain to you "how to do it right".  [The alternative, of course, is for you to just Hire a LabVIEW Developer to do your work for you, but if you are interested in learning LabVIEW, you'll have to put in the effort, yourself ...].

 

Bob Schor

0 Kudos
Message 25 of 33
(1,395 Views)

Getting two Boolean on tow different machines to follow each other is dirt simple and can be done in five minutes.

 

See Help Find Examples >>> Networking >>> Shared Variable >>> Shared Variable.proj

Please Note that example clearly warns it is Lossy.

 

What is not trivial is deciding how to handle conflicts when one PC true and the other says false.

 

You have to first answer that question and "Do you care" etc.

 

Once you have defined those and other details, THEN you can move on to develop code. 

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 26 of 33
(1,396 Views)

Here is the attached code.  The problem is that when the boolean gets switched to true it needs to send the signal to the other VI, THEN wait for an incoming signal.  I currently don't know how to get this to happen sequentially.  the goal is 

 

1) Start the Server

2) Start the Client

3) Click the Boolean on the server

4) Boolean on Client turns True 

5) Click on Client Boolean (Turns it False)

6) Boolean on Server turns false

7) Repeat Steps 3-7 to infinity

 

Thanks!

0 Kudos
Message 27 of 33
(1,396 Views)

Forgot the code above, here it is.

Download All
0 Kudos
Message 28 of 33
(1,392 Views)

Forgot the code above, here it is.

0 Kudos
Message 29 of 33
(1,391 Views)

Go back and reread  Message 17 of this thread.

Write up some pseudocode or a flowchart that does that.

 

Right now you scheme is too simple because you basically have one way communication.  One is either waiting for a message if  the boolean is True, and writing a message if the boolean is false.  The other is doing just the opposite.  And those loops should have some wait statements in there.  If the booleans aren't set correctly, they both can wind up waiting for messages that never come.

 

Let the server be in charge.  Let the client request when it wants to get control, and must return control when done.

 

You'll have to work out what it means in your situation if the client never responds its done to return authority back to the server in the event something happens, like the network goes down.  You can look at timeouts.  I don't know your real world situation, so you'll have to determine what rules each program must follow when communications break down.

0 Kudos
Message 30 of 33
(1,376 Views)