LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP connect disconnect device

Hi!

 

I am building a labview program where I will have multiple independent connected devices through simple TCP/IP protocol. I already established connection for one device. I am using Open TCP connection before While loop and then in while loop I am reading data. I would like to have a button (connect/disconnect) for each device so that I would like to disconnect device from tcp/ip connection without closing labview program and then connect device back. I want other devices to communicate without interruption. How could I achive that?

 

I am quite new to Labview so I do not have a full skillset of all the labview structures and how they realte to each other. I am assuming that I will need a button disconnect/connect and somehow when this button is pressed TCP connection opens and when it is pressed again tcp connection closes. But how to put this in while loop without so that each action is performed only once on button pressed is kind of bugging me now a couple of hours.

0 Kudos
Message 1 of 2
(3,081 Views)

I suggest you start with a simpler problem - make it possible to connect to, and disconnect from, a single device. To do this you'll want to store the TCP refnum in a shift register around the while loop, and move the TCP Open and TCP close inside that while loop. There are a couple of ways you could handle it from here. The simplest solution is to put both the Open and Close in separate case structures, and wire a button to each one, with the button's mechanical action set to latch. One button will be Connect and will cause the TCP Open to run; the other will be Disconnect and will cause TCP Close to run. Give this a try. Later you might use an Event structure instead of the case structures, and you could add some code to determine whether the device is already connected - if so, the Connect button shouldn't do anything.

 

Please attach your code to future posts; it makes it easier to provide specific suggestions.

0 Kudos
Message 2 of 2
(3,046 Views)