11-26-2015 02:29 PM
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.
Solved! Go to Solution.
11-26-2015 02:53 PM
Sounds like you are asking for two, distinct things.
11-26-2015 03:12 PM
Yeah, to verify I can transfer data between two vi through dll is my first step before transferring data from C++ to Labview.
11-26-2015 03:25 PM
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.
11-26-2015 03:58 PM
My final target is to be able to transfer 5M data every second. Therefore I prefer to use dll which should be fast enough.
11-26-2015 04:12 PM
11-26-2015 04:17 PM - edited 11-26-2015 04:20 PM
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
11-26-2015 04:30 PM
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
11-26-2015 04:33 PM
My supervisor did some test and came out that conclusion. That is also why I didn't choose to use dde.
11-26-2015 04:36 PM
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