LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

handshaking between programs

I am calling a DLL created in LabVIEW in Lab Windows CVI. I was wondering if it was possible for the LabVIEW program to send an ACK to the CVI program indicating its running and for the CVI program to use that value or for LabVIEW to setup a variable and for CVI to be able to access it?? 

 

Any help is appreciated! 

 

Thanks

0 Kudos
Message 1 of 18
(4,481 Views)

Hi JCampos,

 

Yes, LV and CVI can both access Shared Variables.  There's an example of this online at

CVI and LabVIEW Network Published Shared Variables

 

However, depending on what you want to do, it may be easier just to put another input in your function prototype and pass a value to your DLL that way from LabVIEW. 

 

Message Edited by Eric S on 06-07-2010 04:27 PM
Eric S.
AE Specialist | Global Support
National Instruments
0 Kudos
Message 2 of 18
(4,442 Views)

I decided to go with the network variables but on the LabVIEW side so there are two VI's that make up my DLL. In CVI, I run my program and a second thread calls the first VI is called and its written to do some setup, set a shared variable to true and wait for another global variable to be set to true. At the same time in CVI since the function call to the DLL was with a separate thread it continues and calls the second VI to then check if the first shared variable was set to true and if so it sets the second global variable to true which should then allow the first vi thats running to now continue on. When that call returns to CVI, the program continues. The shared variables work when running in the LabVIEW environment but running them as EXE's they don't.

 

Essentially I want to start running in CVI, create a thread to run a LabView program and I want the CVI to continue only if the LabVIEW program has reached a certain point in its code so as to avoid a race condition.

 

I hope it all makes sense and help would be great! Also Im running Windows XP, LabVIEW 8.6 and CVI 8.5.

 

Thanks!

0 Kudos
Message 3 of 18
(4,404 Views)

Did you deploy the shared variables from LabVIEW?

 

How Do I Deploy Network Shared Variables from a Compiled Executable?

 

If the variables aren't deployed that could definitely be a reason for it not working, I would try adding in the programmatic method of deploying the variables also. 

Message Edited by Eric S on 06-10-2010 05:55 PM
Eric S.
AE Specialist | Global Support
National Instruments
0 Kudos
Message 4 of 18
(4,376 Views)

Hi Eric S,

So I found that out yesterday so that resolved the EXE issue but now it will not work using the DLL. I have moved the files over to a different computer that does not have LabVIEW and I can see the variables in the variables manager but I cant change them using the DLL, only with the EXE's.

0 Kudos
Message 5 of 18
(4,365 Views)

So you moved both of these files, the DLL and EXE to a new computer?  Or is the EXE on one computer and the DLL on another?

 

Can you read the shared variables from the DLL or can it not communicate with the shared variables at all?

 

Are you getting an error when trying to write to the shared variables from the DLL or is it just not doing anything? 


Does this new computer have both the LabVIEW Runtime and the CVI Runtime for the appropriate versions?

 

Eric S.
AE Specialist | Global Support
National Instruments
0 Kudos
Message 6 of 18
(4,319 Views)

Yes both exe and dll are on this new computer. It cannot read or write to the shared variables through the DLL at all only through the exe. I'm not getting any type of error. It looks like it is making the function call but returning right away without returning an error. The computer has the LabVIEW runtime and the CVI runtime as well.

0 Kudos
Message 7 of 18
(4,256 Views)

I can't say anything about the shared variables approach as I have never used that feature. What I would have done personally is used TCP/IP to maintain a connection. Doing so, I can send any sort of messages I want between programs.

 

There are other ways too, using COM and ActiveX but those would not be my way of doing this as I am less familiar with them and don't feel like going through the learning curve.

 

Just goes to show there are many ways to approach a problem.

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 8 of 18
(4,205 Views)

Using TCP/IP or another protocol is certainly an option, though requires the learning curve on those protocols.

 

JCampos, have you tried calling this DLL from a different programming environment other than CVI? such as c#,c++, or even another LV VI?

 

The DLL you're trying to call was was compiled out of LabVIEW VIs, correct?  What happens if you try calling that DLL from LabVIEW?

Eric S.
AE Specialist | Global Support
National Instruments
0 Kudos
Message 9 of 18
(4,176 Views)

Eric, it's all about what you are comfortable with. I use TCP/IP because I know it intimately. I would have to go learn the shared variables approach.

 

We all have our comfort zones.

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 10 of 18
(4,173 Views)