LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL import and Pointers to a function

Hi,
 
I am currently trying to get the ANT development kit working under LabView. For that i have imported the dllL (with the 8.2 version of LabView because of unknown reasons the import doesnt work under 8.5).
 
everything seems to work fine except one thing.
In the dll there is a function
void ANT_AssignResponseFunction(RESPONSE_FUNC pfResonse, UCHAR* pucResponseBuffer); // pucResponse buffer should be of size MESG_RESPONSE_EVENT_SIZE)
 
that needs a application callback function pointer as defined in the header (all files are attached)
 
// Application callback function pointer
typedef BOOL (*RESPONSE_FUNC)(UCHAR ucANTChannel, UCHAR ucResponseMsgID);
 
labview doesnt import the ANT_AssignResponseFunction propperly because it does not recognize RESPONSE_FUNC pfResonse. I have tried several things i have found in the forum and helpsites eg. with mathscript and so on but nothings working, and this and other functions that are built the same way need to work to read data... the example usage from the ant protocol in c looks like this
 

// Example Usage

BOOL ANT_ResponseFunction(UCHAR ucChannel, UCHAR ucResponseMesgID);

UCHAR aucResponseBuffer[MESG_RESPONSE_EVENT_SIZE];

..

ANT_AssignResponseFunction(&ANT_ResponseFunction, aucResponseBuffer);

 
but how can i get this working in labview? i have attached all files.
 
Please help me.
thanx a lot
martin
0 Kudos
Message 1 of 6
(3,758 Views)
Hi! You need to create the wrapper-DLL, where you should define your callback function. When this function called, you can notify LabVIEW about this by sending the message, or by triggering the Occurence. with best regards, Andrey.
0 Kudos
Message 2 of 6
(3,743 Views)

hi,

 

first: thanx for the answer. i've already tried to buidl a wrapper dll (in labview) but the problem is, that i dont get the correct prototype that should look like this

 

BOOL (*RESPONSE_FUNC)(UCHAR ucANTChannel, UCHAR ucResponseMsgID);

 

How do i get the pointer as returntype?

 

thanx a lot

martin

0 Kudos
Message 3 of 6
(3,728 Views)
I think, in LabVIEW its will be complicated (or impossible). You should create the wrapper in MS Visual Studio or in in NI CVI.
 
best regards,
 
Andrey.
0 Kudos
Message 4 of 6
(3,717 Views)

hello,

thanks for the answeres. that the dll creation doesnt work with labview ist bad for me, cause my prog skills are very littel. has anyone a link to a good tutorial or so that can help me to create the wrapper dll.

 

thanx a lot

martin

0 Kudos
Message 5 of 6
(3,712 Views)


@martinboecskoer wrote:

hello,

thanks for the answeres. that the dll creation doesnt work with labview ist bad for me, cause my prog skills are very littel. has anyone a link to a good tutorial or so that can help me to create the wrapper dll.



If you don't know C already you would have a very steep learning curve. C in itself is already quite a bit to learn but pointers and expecially function pointers are another step higher in the knowledge ladder when learning C programming.

What is it for and can you afford to pay someone to do this for you? Because doing it yourself will certainly take you lots and lots of hours of work with an outcome that might appear to work but will quite likely crash under exotic curcumstances such as when you have shipped the entire applciation to the other side of the globe.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 6
(3,707 Views)