DataSocket Read Not Waiting for a DataSocket Write in LabVIEW

Updated Mar 16, 2023

Reported In

Software

  • LabVIEW

Issue Details

I have a DataSocket Read function in one VI and a second VI that uses a DataSocket Write function to publish data. If I run the DataSocket Read VI first and then the Write VI, I expect the Read VI to wait until it receives the data from the Write VI and then output that data. However, it doesn't wait, and instead outputs a default value.  How can I achieve my desired behavior from these VIs?

Solution

Whenever a DataSocket item is created, there is a default value assigned to it. When you execute a Read function, that default value is returned. To force the DataSocket Read to wait for a new value from a DataSocket Write, you need to do the following:
  1. After the DataSocket Open function in your block diagram, perfom a Datasocket Read. This will read the default value that was assigned to the DataSocket, which you can ignore.
  2. Place a DataSocket Read where you want to wait for a value from the write. Be sure that you wire a TRUE into wait for updated value (T) terminal. If you wire in a false, it will ignore the timeout terminal. So now the Read will wait for a new value to update the DataSocket.