From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading old data from network variables

Hi,

I am using LabWindows/CVI 8.5 and LabVIEW 8.6. I am using network variables to communicate between CVI and LabVIEW. I dont have a problem writing but when I read from CVI I found that I am getting old data not the latest value. I am using CNVCreateReader, CNVRead to connect and read to the network variables. I know that the first subsequent CNVRead after CreateReader retrieves the value during that connection so I placed the CreateReader function at the point in my code where the value was already updated for about 20 seconds but when I do the read I get a previous reading not the latest.

 

 

Any help would be greatly appreciated.

Message 1 of 6
(3,168 Views)

I do not see this behavior with CVI 2010 - the CNVRead function gets the latest unread value or timesout if the value has not changed since the last read operation. It is possible that your variable is buffered on the server and this is causing this behavior or it could be something else like the write operation was not able to update the value on the server. You could try checking the current value of the variable using the Distributed System Manager (previously known as Variable Manager) utility and see if this corresponds to the value returned by CNVRead. Also, make sure you are checking the return value of CNVRead to make sure it is not returning an error code.

 

Anyway, for reading network variables as and when they change, the Subscriber is a better connection to use. Also, when you use the subscriber you can get the value the variable had during connection using the CNVGetConnectionAttribute function and getting the CNVMostRecentDataAttribute. This may be a better solution for your use case. Please check out samples/networkvariable/subscriber for an example of using the subscriber connection.

0 Kudos
Message 2 of 6
(3,155 Views)

I use CVI2010 and still see the same problem. I use the Subscriber and it still shows that I got the old data back.  I know I got the old data because my labview realtime running on the pxi controller reading back from the same network variable shows the new data.  The workaround that I am doing now is to read a few times, this is not an efficient with a large array. 

0 Kudos
Message 3 of 6
(3,122 Views)

I use CVI2010 and still see the same problem. I use the Subscriber and it still shows that I got the old data back.  I know I got the old data because my labview realtime running on the pxi controller reading back from the same network variable shows the new data.  The workaround that I am doing now is to read a few times, this is not an efficient with a large array. 

0 Kudos
Message 4 of 6
(3,122 Views)

Never mind, I was mistaken, I used the BufferedSubscriber and I thought the first read to the buffer would return the last write, however it was first in first out, not last in first out.

0 Kudos
Message 5 of 6
(3,120 Views)

Well, reviving this old thread.

 

I'm running into the exact same issue using CVI 2020 with Labview 2017. Labview is the writer and in CVI I have a normal CNVReader (not subscriber!) because I only want to read values when commanded to do so (usually shortly after an update). The command is sent from labview (via NS) after labview itself has checked that the NV updated to the correct value (because of timing issues between updating the NV and sending the message via NS), so the NV should really be updated and done.

 

The NV in labview is set to not use buffering. I used the NI Distributed System Manager to check that the values are updated by checking that the timestamp updates. I haven't checked the actual data (around a million values are sent...) but I am confident it is correct based on dimension checks from labview.

 

Any clue what could cause this behaviour?

0 Kudos
Message 6 of 6
(1,060 Views)