04-20-2020 11:28 PM
Hello,
LabVIEW is reporting error 1584 when I attempt read-only access of an external data value reference using an in place structure. Is this a bug in LabVIEW, or a limitation of external data value references? This problem does not occur for (internal) data value references.
Note that I used https://forums.ni.com/t5/LabVIEW/Creating-EXTERNAL-data-value-references/td-p/3873039 as a hint how to create external data value references, and have attached sample code that demonstrates the problem (please note that I have only tested this using LabVIEW 2018 64-bit). Beyond that, the creation of external data references is undocumented, and the code I have arrived at is through some trial and error.
Many thanks,
Stephen
04-21-2020 01:29 AM
Is there a reason why the right border node is not wired? If I wire it from the left border node I receive no error. (LabVIEW 2018 SP1 32bit).
04-21-2020 01:40 AM
Thanks for your reply. Yes, that was intentional as leaving that unwired is how read-only access is obtained, according to the manual:
"You can enable read-only access to the data value reference by right-clicking the border node on the right of the structure and selecting Allow Parallel Read-only Access. When the border node on the right is unwired, LabVIEW allows multiple, concurrent read-only operations and does not modify the data value reference."
Wiring that node writes to the memory location.
04-21-2020 01:52 AM - edited 04-21-2020 01:54 AM
My guess is that LabVIEW has no way of making sure that your external code won’t attempt to update the content of the internal value somehow while it attempts to read it. This could be a fundamental limitation Maybe it could be enabled by having your external code set an extra property on the DVR at start and make sure to always call an explicit lock and unlock function or the existing one with a special flag that indicates if your access is read only or not.
The safe thing to do here is to error on the safe side so I’m sure you need to do some extra work in order to allow comcurrent access. If that extra work is available for an EDVR I don’t know. It may not be, or not documented or you just haven’t seen it.
04-21-2020 02:13 AM
Although I am passing NULL pointers to functions, the external data reference allows setting a lock reference callback function pointer (pLockRefCallbackFunc) and an unlock reference callback function pointer (pUnlockRefCallbackFunc). There is no documentation, but my guess is that LabVIEW calls these functions to notify external code when it is accessing the data.
I admit I haven't tried setting these yet (defining these functions in my specific application would make no difference). I'll try giving LabVIEW pointers to functions to call and report back.
I suspect something else is going on here, though, as the error description is "The data in the reference cannot be resized. There is a size mismatch between the data in the reference and the data wired to the Data Value Reference Write Element border node.". To me this suggests LabVIEW is still trying to write to the location, even though with the terminal disconnected it isn't supposed to.
04-21-2020 07:31 PM
I created a dll to provide callback functions pointers, yet still get error 1584 when attempting read-only access of the external data and the code reaches the write terminal of the in place structure.
This testing has also shown that when using an in place structure to perform read/write access to the external data, LabVIEW calls the lock then unlock functions when entering/leaving the in place structure. When I try to perform read-only access, LabVIEW does not call the lock and unlock functions, which makes sense. I have attached new code along with the dll it works with, but please note that this dll was build for 64-bit, and so will only work with 64-bit LabVIEW.
Does anyone have NI Vision? If so, can you please check whether you get error 1584 when you attempt read-only access to the external data value reference returned by the IMAQ ImageToEDVR VI?
Many thanks,
Stephen
04-21-2020 09:41 PM
I downloaded the evaluation version of the Vision Development Module, and then opened the "Image to EDVR.vi" example. I modified data value reference read-only access, and LabVIEW reported reported the same error, i.e.:
--
Error 1584 occurred at Data Value Reference Read / Write Element in Image To EDVR.vi
Possible reason(s):
LabVIEW: (Hex 0x630) The data in the reference cannot be resized. There is a size mismatch between the data in the reference and the data wired to the Data Value Reference Write Element border node.
--
This gives me greater confidence that I am creating external data value references correctly, and that I have either discovered a bug or limitation in LabVIEW. At this point I will get in contact with National Instruments support.
04-23-2020 10:19 PM - edited 04-23-2020 10:21 PM
I thought I'd provide the following update that National Instruments have replicated the issue and are investigating it further.
In the meantime I managed to verify that LabVIEW does not write to the external memory if the read terminal is directly wired to the write terminal. I verified this by allocating the external memory using VirtualAlloc and setting PAGE_READONLY memory protection so that LabVIEW would cause an access violation if it attempted to write to the memory. Subsequently, LabVIEW caused an access violation and crashed if the in place structure was configured for read-only access to the external data value reference or if it attempted to write modified values, but not if I wired the data value reference read terminal directly to the write terminal (i.e. if there was no change to the values by LabVIEW).
05-10-2022 10:31 AM
Wow, thanks for the in-depth analysis! This is *really* helpful to know!
I wanted to use this "read-only" feature simply to avoid the unnecessary write operation.