Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asynchronous DLL access in LabVIEW?

Tags:

dll

labview

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?

like image 935
dwj Avatar asked Jul 23 '09 23:07

dwj


1 Answers

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 *)&param);
return 0;
}

And here's the original sourcecode as a PNG: alt text
(source: vi-lib.com)
And here is the accompanying LabVIEW code:
alt text
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.

like image 129
Ton Plomp Avatar answered Sep 20 '22 12:09

Ton Plomp