Showing results for 
Search instead for 
Did you mean: 

What is the best way to stream data from a C-Program to a LabVIEW VI?

Go to solution

Dear Community,

I'm currently working on a project where I'm programming a device control with LabVIEW. A colleague of mine is programming some image analysis with C, where he calculates about 3 paramateres per image every ~30 ms.

Now we want to use these parameters in my VI.
So the idea was to continuously wirte the parameters with the C-Program to a file and simultaneously read from that file with my LabVIEW VI.

For performance reasons the C-Program and LabVIEW VI are running on two different PCs.

My first idea was to use a TDMS file in a shared directory. But after my first tries with TDMS I have some doubts if this is the best solution, because I had some trouble while testing with an .exe to write some TDMS files and simultaneously reading it.
So I just want to ask if you guys know a better solution for our problem?

0 Kudos
Message 1 of 6

I don't think using files is going to be the best way to go here.

I think you probably want to use something like a Network Shared Variable.

0 Kudos
Message 2 of 6
Accepted by topic author s_bohn

Is there a C interface for shared variables?

TCP is a very good option. STM provides a good template to follow for an implementation. There's even a C client

Message 3 of 6

@nanocyte wrote:

Is there a C interface for shared variables?


According to the whitepaper that I linked:

"In addition, with the Network Variable Library introducted in NI LabWindows/CVI 8.1 and NI Measurement Studio 8.1, you can read and write to shared variables in ANSI C, Visual Basic .NET or Visual C#."


I haven't used the ANSI C interface to Measurement Studio myself. Should be pretty straightforward though.

0 Kudos
Message 4 of 6

As a possible way to make it simpler, you could use LabVIEW to build a DLL that accesses the shared variable instead of making your C programmer wade through a new API.

0 Kudos
Message 5 of 6

Thank you all guys,


I think just using TCP will be the best solution for me.

0 Kudos
Message 6 of 6