LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling one dll from two VIs

Solved!
Go to solution

Hi, I have two VIs, one is "data generator" and another one is "data receiver". I'm wondering if I can build a dll through which the "data generator" can transfer data (say a boolean) to the "data receiver"? I want to know this because I need to transfer data from a C++ program to my Labview program.

0 Kudos
Message 1 of 14
(3,784 Views)

Sounds like you are asking for two, distinct things.

 

  1. There is an easy way to transfer data from a C++ dll to your LabVIEW VI via Call Library Function nodes.
  2. There are more well defined and standard ways of transferring data between two VIs. If the VIs are running independently then there are data synchronisation mechanisms (queues, notifiers) to transfer data between them in a thread-safe and asynchronous manner.
Message 2 of 14
(3,773 Views)

Yeah, to verify I can transfer data between two vi through dll is my first step before transferring data from C++ to Labview.

0 Kudos
Message 3 of 14
(3,763 Views)

If you want to get data from your C++ code with an explicit call, simply create a function which returns it and call that function from LV.

 

If you want to push data from your C++ code to LV, use the PostLVUserEvent function, which allows you to generate events in C and get them in LV.


___________________
Try to take over the world!
Message 4 of 14
(3,754 Views)

My final target is to be able to transfer 5M data every second. Therefore I prefer to use dll which should be fast enough.

0 Kudos
Message 5 of 14
(3,741 Views)
Why would you think your dll is faster? Please post your benchmark.
Message 6 of 14
(3,725 Views)

So this data is in an application that is written in C(++)? In that case I have bad news for your idea,

 

You can not share data through a DLL between two processes. Each process loads the DLL into its own protected memory space. Data written from your C++ process into some variable inside the DLL will not be visible from LabVIEW when it loads this same DLL (but with a seperate data space). There is no easy way to change this, that is how Windows treats DLLs and that is for a good reason, as we have long passed the time where applications run all in one single memory space. If Windows wouldn't do this, any application could basically read anything from any other application, which would be a complete security disaster.

 

You would need to implement Inter Application Communication (IAC). This can be done through TCP/IP, shared memory or other mechanismes.

 

If you didn;t mean your C++ side to be a process you will need to explain in more detail what you have planned

Rolf Kalbermatter
My Blog
Message 7 of 14
(3,714 Views)

That is bad news to me as TCP is not fast enough. Can I use a shared data segment in the dll?   http://www.codeproject.com/Articles/240/How-to-share-a-data-segment-in-a-DLL

0 Kudos
Message 8 of 14
(3,704 Views)

My supervisor did some test and came out that conclusion. That is also why I didn't choose to use dde.

0 Kudos
Message 9 of 14
(3,702 Views)

TCP is a good option for you - you're connecting on 127.0.0.1 on loopback which never gets near the physical network. See this link: http://serverfault.com/questions/234223/how-fast-is-127-0-0-1

Message 10 of 14
(3,695 Views)