LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with DataSocket!!!!!!!!!!!!!!!

I have two networked PC's and am using DataSocket to transfer some information between the two of them. My process involves launching and closing different VI's based on what is going on with the process. Here is the problem: A boolean from the master PC is sent to the slave PC that tells it to shut down a certain VI, and the VI shuts down. Now when the process calls for that VI to be called again it retains the last boolean value it read and shuts down immediatly. It seems to me that DATASOCKET READ WILL REMEBER THE LAST VALUE THAT IT READ AND IF THE WRITER IS NOT RUNNING IT WILL SPIT THIS VALUE OUT. I want to set it to a default value before I start reading again but am having trouble accomplishing this. Does anyone out there
know what I am talking about. Anyone know how to get around this???
0 Kudos
Message 1 of 6
(3,608 Views)
You have a handshaking problem here. Once you write a value to a datasocket, the server will remember it. Just because your slave PC reads a value does not mean that the value should go back to default or even change at all. You must write to that datasocket to change it. I would suggest that you have your slave VI detect the shutdown boolean and then write a FALSE to it before shutting down. That way, the next time the VI is run, the boolean will be back in its default state.

WARNING: I have noticed that the VI that writes to the datasocket must keep running for a bit after the write operation. For some reason, if a VI writes to a datasocket and then terminates, the data sometimes fails to get to the server. That is odd behavior for sure. I have sp
oken to NI support about it too. Just make sure that before your VI terminates, that it writes to the datasocket and then confirms it by reading it back.

Good luck,

Daniel L. Press
NI Certified LabVIEW Developer
PrimeTest Corporation
www.primetest.com
0 Kudos
Message 2 of 6
(3,608 Views)
Datasocket is Asynchronous. There may actually be a way to set it to synchronous, as there is with VISA calls.

Asynchronous behaviour is somewhat counter-intuitive in a dataflow regime, and most programmers are neither aware, nor familiar with this concept.

If this is the case, and for everyone else out there, asynchronous behavior is essentially this. If you make a call to an asynchronous VI or function, that function will execute regardless of the dataflow in the calling VI, unless of course you shutdown the function early by externally terminating it (as seems to be happening in this issue.) Synchrounous behavior means that the function is dependent upon the caller, and will only release the caller once the function has completed executing.


Admittedly, this is a very rough estimation of the two behaviors, but it should give adequate explanation to those not familiar with the two terms.

Hope it helps anyway...
Message 3 of 6
(3,608 Views)
> I have two networked PC's and am using DataSocket to transfer some
> information between the two of them. My process involves launching
> and closing different VI's based on what is going on with the process.
> Here is the problem: A boolean from the master PC is sent to the
> slave PC that tells it to shut down a certain VI, and the VI shuts
> down. Now when the process calls for that VI to be called again it
> retains the last boolean value it read and shuts down immediatly. It
> seems to me that DATASOCKET READ WILL REMEBER THE LAST VALUE THAT IT
> READ AND IF THE WRITER IS NOT RUNNING IT WILL SPIT THIS VALUE OUT. I
> want to set it to a default value before I start reading again but am
> having trouble accomplishing this. Does anyone out there know
what I
> am talking about. Anyone know how to get around this???

Datasocket is appropriate for reading and writing the current value of a
variable. It is not appropriate when you need handshaking such as this.

You might be able to make it work sometimes by writing back to the
variable and/or adding delays to the writers and readers, but the real
solution is to use a distributed function rather than distributed data.

Use the VI Server to open a connection to the remote LV, then use the
built in operations to intract with a given VI, such as aborting it.
Better yet, you wrap something like a global or occurrence in a subVI.
The remote machine can pass on all sorts of messages between the
machines by manipulating which things are wrapped.

Greg McKaskle
0 Kudos
Message 4 of 6
(3,608 Views)
Thanks for the information!
0 Kudos
Message 5 of 6
(3,608 Views)
Thanks! I'll give it a try......
0 Kudos
Message 6 of 6
(3,608 Views)