I have a LabVIEW application that current sends data to a C++ application via a DLL. I now need to send data back to the LabVIEW app from the C++ one. Can I trigger code in LabVIEW from a DLL call or will I need to poll the DLL periodically to see if new data is waiting?
Or am I going about this in completely the wrong way?
It is possible to generate an event from C++ to trigger a normal LabVIEW event.
Here is a NI forums post discussing this structure.
And a code excerpt from that thread:
#include <utility.h>
#include <extcode.h>
#include "EventDLL.h"
//Generate a LabVIEW event
int GenerateLVEvent(LVUserEventRef *msg, int param)
{
PostLVUserEvent( *msg, (void *)¶m);
return 0;
}
And here's the original sourcecode as a PNG:
(source: vi-lib.com)
And here is the accompanying LabVIEW code:
The lower loop is LabVIEW code that sends a DLL event to the LabVIEW event handler.
This should be placed inside your DLL.
One of the input parameters should be the event pointer as a U32.
Good luck,
Ton
PS if you are going do dive into DLLs and LabVIEW interoperability, pay attention to everything RolfK says, he is a guru in that field.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With