Example Code

Real-Time Remote Procedure Call with STM

Code and Documents

Attachment

Download All

Functional Description

This VI is an example demonstrating the ability to remotely launch an application on an Real-Time (RT) target with VI Server, and then connect with STM for future data exchange, and shared variables to easily stop multiple loops on the remote target. VI server is the best choice for remotely launching, STM is the best choice for data communication, and shared variables is the best choice for easily stopping multiple loops on a remote application.

  1. Initialize a network stop shared variable to false. This is the SV that the RTexe uses to control its loop. I want it to be false so when the rtexe starts, it doesn't immediately stop.
  2. Connect via VI server to the RT target. Make sure the RT target has tcp VI server access enabled in your project. Right click -> properties
  3. Open a reference to the main VI inside my deployed rtexe. This rtexe is NOT set as startup, but it is deployed on the target.
  4. Run the VI.
  5. Wait for a bit to make sure the rtexe is up and running
  6. Open TCP connection
  7. Transfer STM meta data
  8. Enter the main loop, check for STM messages
  9. When the host main loop is stopped, in a subVI set the network stop SV to true, stopping the rtexe. I do this in a subVI so I can wire the error terminals through it to maintain dataflow, but in the subVI I don't wire those error wires through the SV. If an error is wired into a SV, the SV node will not execute. This way I can have dataflow, and I can make sure that I write a true to the network stop no matter if I have an error or not.
  10. Wait.
  11. Close TCP connection.

RT RPC with STM.PNG

Caveats and Additional Notes

You will have to fill in the blanks here. The case structures, the remote application, the STM meta data... etc. Make sure the remote application is built into an executable and transferred to the RT target, also not set to run as startup.

Stephen B

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors