12-15-2009 06:20 PM
Hi. I've searched and found some possible solutions, but I'm still a little confused and wonder if you could help?
I've got a game developed in VC++ using the SDL graphics libraries. I want send the coordinates of a character and targets into a VI which will do some calculations for the target and read in a joystick position. The new character position from the joystick, and the new position of the target are then sent back to the c++ program and the graphics are updated.
Is this at all possible? What is the best approach? I've looked into activex and dlls but haven't really found an addequate solution as yet.
Thanks so much in anticipation...
Ted.
12-16-2009 02:19 AM
Just my hints:
If you only passing simple datatypes like strings or integers I would prefer a DLL. If they might be a bit complex, like arrays I would use ActiveX.
12-17-2009 06:59 PM
12-20-2009 06:06 AM
I'm sorry that I cannot point you to some examples creating DLLs in C++, but google should know it.
And just do a search at ni.com in how to call this dll in LV then via the Call Library Function Node.
Christian
12-20-2009 09:42 AM
tedthemouse wrote:
Is this at all possible? What is the best approach? I've looked into activex and dlls but haven't really found an addequate solution as yet.
There is no "best" approach. It all depends on the circumstances and requirements. What are your specific requirements that lead you to conclude these are not adequate? Is it speed? Complexity? Unfamiliarity with how to use it? Platform independence?
12-22-2009 08:55 AM
Hi,
These are the options I've come up with so far:
* DLL - I can't compile the c++ as a DLL as I run this as an executable game. I thought I could use a DLL to pass data between the two, but it seems that they create their own instance in Labview and c++ and the variables are not shared.
* Activex - I was put off by this as other forums seemed to suggest it was quite complicated...
* Command prompt - I was thinking I could trigger the game exe from labview using the system exec function, and then write and read data between the two programs from the command prompt. This seems very inefficient.
* Shared/Network variable - This is the way I wanted to go, especially if we have a cRIO in the loop. I've managed to create a shared variable between Labview and visual studio through measurement studio, but this works on a MFC library and my game runs as a WIN32 console application. I can't seem to access the shared variable from c++.
I've looked all over the internet and haven't found many examples of how to do this. I know I'm missing something and any help you have would be fantastic!
Thanks so much,
Ted.
12-24-2009 01:47 AM
You missed quite a few options:
- file storage: write information into a file and read it from the other side. Advantage: easy; Disadvantages: slow
- pipe communication: using Windows API functions to communicate through named pipes between the application. Advantage: nice and clean; Disadvantage: complicated Windows API calls
- shared memory: using Windows API functions to communicate through shared memory between the application. Advantage: nice and clean; Disadvantage: complicated Windows API calls
- TCP/IP: creating either in your C++ or LabVIEW app a TCP/IP server and communicate through that. Advantage: nice and clean; Disadvantage: complicated Windows API calls on C++ side.
01-24-2010 07:15 PM
Thanks very much for all your help and advice.
I've made a Labview TCP server that sends and recieves data from a client written in c++. I've now integrated this into the game and Labview is picking up the player positions to perform calculations and adjust feedback to the joystick.
Thanks again,
Ted.