NI Linux Real-Time Discussions

Showing results for 
Search instead for 
Did you mean: 

Best Practices for Latest Value data comms from LabVIEW to C application

I'm considering porting an existing C++ Windows console app over the my RT Linux cRIO.  The current application uses Shared Variables to pass data back and forth between the C App and the LabVIEW App.  The C App will have to run as a Service on the cRIO.




0 Kudos
Message 1 of 3



Is your cRIO target ARM-based or x64-based? The difference being "not currently possible" vs. "not currently supported and will likely take some work on your part".


In other words, while you already have an existing project, it may make sense to use a native and/or open data sharing paradigm (shared memory or another IPC if it's local or a publisher/subscriber network message queue, e.g. zeromq)

0 Kudos
Message 2 of 3

Hey Kevin,


I recently developed a LabVIEW library that implements a few Linux IPC mechanisms for LabVIEW RT. It'll be officially put on the Tools Network before NI Week, but you can get a copy of it now from the NI Systems Engineering Github page.


Linux RT IPC Beta Release


In your case, you'll want to use the Shared Memory VIs that the library provides. Essentially, it is just a native LabVIEW wrapper for the Linux shared memory functions. You can create a shared memory file (C or LabVIEW can do this). The other application will then open a reference to the newly created shared memory file. With both C and LabVIEW referencing the same file, you'll then do a Memory Map on both sides. This gives you a pointer to the shared memory space. At this point, anything one writes to shared memory the other will see, and vice versa. In LabVIEW, the pointer comes in as a U64, but as long as you are just wanting to read/write standard data types (numerics, booleans, arrays of these, etc.), you can use the Write and Read Pointer VIs provided with the library. This pointer also works with the LabVIEW Memory Manager functions, but if you haven't used those then I wouldn't try and mess with them right away.


I recommend clicking "Show Examples" in VI Package Manager when you install the IPC package. I include a shared memory example that provides C executables for both out ARM and x64 targets, as well as a list of instructions for how to get the C and LabVIEW applications running together.


One last thing, the package also includes implementations for POSIX mutexes, conditional variables, semaphores, and barriers. So, if you need to synchronize threads in C with threads in LabVIEW, you can do that too. But the examples for those are not in the package yet, so you'll probably need some experience with those to know what to do.

Ryan P.
0 Kudos
Message 3 of 3