[英]LabVIEW Shared Variables cannot be programmatically accessed from cRIO Real-Time
I would like to use programmatic access to manipulate shared variables on a computer and an NI cRIO 9033, but cannot get programmatic access to shared variables on the cRIO. 我想使用编程访问来操作计算机和NI cRIO 9033上的共享变量,但无法通过编程访问cRIO上的共享变量。
I have boiled the situation down to a very simple example to try to explain what I am seeing. 我将情况简化为一个非常简单的示例,试图解释我所看到的。 The shared variables are hosted on the cRIO.
共享变量托管在cRIO上。 I am using the same VI to perform the accesses on the computer and the cRIO.
我正在使用相同的VI在计算机和cRIO上执行访问。 On the computer, access to the shared variable via a shared variable node and programmatic access both work.
在计算机上,可以通过共享变量节点访问共享变量,也可以通过编程方式访问。 On the cRIO, access to the shared variable via a shared variable node is functional, but programmatic access to the shared variable does not work.
在cRIO上,可以通过共享变量节点访问共享变量,但是无法以编程方式访问共享变量。
The error code received when trying to to a Read Variable or Open Variable Connection on the cRIO to the shared variable is -1950678943. 尝试在cRIO上与共享变量建立读取变量或打开变量连接时收到的错误代码为-1950678943。 The error text reads "Timed out while attempting to open a connection to the variable."
错误文本显示为“尝试打开与变量的连接时超时”。
I'm quickly becoming confused as to why the cRIO should have trouble reading a shared variable programmatically that is hosted on itself. 我很快就对为什么cRIO在以编程方式读取自身托管的共享变量时遇到麻烦感到困惑。 The web searches I have done haven't turned up such a simple scenario causing this error, so I'm wondering if I've stumbled into a beginner mistake.
我进行的网络搜索还没有出现导致这种错误的简单情况,所以我想知道我是否偶然发现了一个初学者错误。
Back Panel of the VI for accessing the shared variables: VI的后面板,用于访问共享变量:
Result of running VI on the computer (all shared variable accesses - via shared variable nodes or programmatic access work): 在计算机上运行VI的结果(所有共享变量访问-通过共享变量节点或编程访问工作):
Result of running VI on the cRIO (all attempts at shared variable programmatic access do not work): 在cRIO上运行VI的结果(对共享变量编程访问的所有尝试均无效):
EDIT: I appreciate the help troubleshooting this, but in the end I couldn't get shared variables to work for my application of programmatic access from a CompactRIO. 编辑:我感谢帮助解决此问题,但最后我无法使共享变量对从CompactRIO进行程序访问的应用程序起作用。 I instead chose to use Network Streams , which seem to function fairly well.
相反,我选择使用“ 网络流” ,它似乎运行得很好。 Upside: Connection details between my client and server can be better encapsulated, since shared variables no longer need to be given to them to allow communication.
好处:客户端和服务器之间的连接详细信息可以更好地封装,因为不再需要将共享变量提供给它们以进行通信。 Downside: a bit more book-keeping to ensure that both reader and writer to the Network Stream are connected correctly (I found this dissection at National Instrument's forum useful when formulating that logic).
缺点:要多做一些记账工作,以确保网络流的读写器都正确连接(我在National Forum的论坛上发现了这种剖析,在阐述这种逻辑时很有用)。
It is difficult for me to reproduce your problem without your architecture. 如果没有您的体系结构,我很难重现您的问题。 Could you try making a test VI with the structure shown here and let me know what happens?
您能否尝试使用此处显示的结构制作一个测试VI,让我知道会发生什么? (Plug in your variable library path where I have an empty library constant).
(将您的变量库路径插入其中有一个空库常量的位置)。
A couple of things to note: 需要注意的几件事:
Variable Names
output will only show values up to that variable. Variable Names
输出将仅显示该变量之前的值。 Read Variable
VI instead of accessing the variables name with the Variable Property Node
, but I figured the name would help you locate which variable is causing the problem. Read Variable
VI,而不用Variable Property Node
访问变量名称,但我认为该名称将帮助您找到引起问题的变量。 Hopefully just explicitly opening a connection before reading from your variable will solve the problem, but let me know what ends up happening on your end. 希望在读取变量之前先显式打开连接即可解决该问题,但请让我知道最终会发生什么。
Edit: 编辑:
After a bit of discussion, I modified the VI to include a short delay at the beginning before we try to access the shared variable engine. 经过一番讨论,在尝试访问共享变量引擎之前,我对VI进行了修改,使其在开始时包含一小段延迟。 The shared variable engine needs a bit of time to start up, so it could be failing to start up before timing out.
共享变量引擎需要一点时间才能启动,因此它可能在超时之前无法启动。 You could adjust the delay a bit and see if that solves the problem.
您可以稍微调整一下延迟,看看是否可以解决问题。
Here are some additional troubleshooting tips from NI. 以下是NI提供的一些其他故障排除技巧 。 A big one to double-check is that your shared variables are, in fact, deployed.
需要仔细检查的一个重要方面是,实际上已经部署了共享变量。 If you can access them from the PC though, then I would imagine that they are deployed.
如果您可以从PC上访问它们,那么我可以想象它们已部署。
Another thing to note: if you are using your variables in a loop on your RT machine, make sure that there is some delay between iterations of the loop. 需要注意的另一件事:如果您在RT机器的循环中使用变量,请确保循环迭代之间存在一定的延迟。 The shared variable engine can get starved out by RT loops if they do not leave time for the processor to handle lower-priority tasks.
如果共享变量引擎没有为处理器留出时间来处理较低优先级的任务,它们可能会被RT循环饿死。
Lastly, just wanted to throw up a link to the documentation on network shared variables. 最后,只想抛出一个指向网络共享变量文档的链接。 There is a lot of useful information in there, although I am not sure that it necessarily helps with this issue.
尽管我不确定它是否一定有助于解决此问题,但其中有很多有用的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.