01-14-2009 03:27 PM
I currently have a LabVIEW VI which grabs data (range and angle measurements) from the RS232 serial port, and formats this data into two values - X and Y coordinates (double data types). What I want to do is pass these individual numerical values (not an array of X/Y coordinates) to a C++ gesture recognition program that inputs X and Y coordinates and determines the gestures.
What is the best way of passing a value from LabVIEW to C++ code?
I apologize if this was answered in another thread - I searched through some, but couldn't find any information relevant to my question. Thanks for the help!
01-15-2009 03:47 AM
Hi delvec28,
delvec28 wrote:I currently have a LabVIEW VI which grabs data (range and angle measurements) from the RS232 serial port, and formats this data into two values - X and Y coordinates (double data types). What I want to do is pass these individual numerical values (not an array of X/Y coordinates) to a C++ gesture recognition program that inputs X and Y coordinates and determines the gestures.
What is the best way of passing a value from LabVIEW to C++ code?
I apologize if this was answered in another thread - I searched through some, but couldn't find any information relevant to my question. Thanks for the help!
You may want to build a DLL. A DLL is like a collection of functions - compiled in a way to be used by other programs.
If the C++ code calls a LabVIEW function which returns values to the C++ code, then the LabVIEW code will be compiled as a DLL.
C++ code could also be compiled into a DLL usable by LabVIEW.
There are also ways for separate applications to share data - LabVIEW can be an ActiveX server, LabVIEW also supports DDE (Dynamic Data Exchange) - these are both Windows-OS-specific. LabVIEW can be a .NET client, though (as far as I know) LabVIEW cannot yet implement a .NET server.
TCPIP is yet another (OS independent) method of sharing data between LabVIEW and another application - it's really not too complicated (at least not on the LabVIEW side .)
Are there two applications running (C++ + LabVIEW)? If not, in which language is the main program written in?
Cheers!
01-15-2009 04:37 PM
I'm currently working on the LabVIEW portion of the program, but the C++ code was already developed and used in another standalone project that did not involve LabVIEW. To my understanding this program constantly accepts a stream of XY coordinate values and calculates if the path matches pre-determined gestures. To be honest, I have not even seen this C++ code, I just have a general idea of the functionality.
So from my perspective, I'm receiving and formatting the raw positional data (XY values) from the serial port at specific intervals (XY data is received approximately 6x per second). For each iteration of the while loop within LabVIEW, I want to pass the current XY data to the C++ program. At this stage, I don't know whether the LabVIEW or C++ program will be considered the 'main' program.
I think for now, I'd like to implement the C++ program as a background process within the LabVIEW program. Any thoughts on which method or suggestion would be best suited for this application?
Another question - I found this link which gives some example C and LabVIEW code for sharing data - http://zone.ni.com/devzone/cda/epd/p/id/6117. There is one problem though, I receive error code 9 because this example was developed in LabVIEW 8.6, while I'm using 8.5. Is there any way to make this example backwards compatible, or are there any similar examples for 8.5?
Thank you, I appreciate the information.
01-16-2009 01:48 AM
Hi delvec28,
I too am unable to open the LV 8.6 examples!
Here's an example of what you've described. "Static" variables are declared inside the initial call to the dll, and the variable addresses are returned to LabVIEW which then passes them to a DLL "process". LabVIEW can update the variables at any time and the process can read them. In the example, both LabVIEW and the process are constantly polling the variables - quitting when either is changed. To use this technique to pass values indefinately, it probably makes sense to have an additional flag (U8) which LabVIEW would set ON to indicate when new values were written - and which the process would clear when it read them.
Cheers!