LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement a callback function using LabView's Call Library Function Node?

Solved!
Go to solution

Yes, I found all those links, but I haven't how to actually use the PostLVUserEvent() function. In all the examples I've found so far regarding callbacks noone is actually using that function. I tried searchin in the NI directory for the function, but again couldn't find it. My LV help shows nothing about it. Is it an obsolete function?

 

George

0 Kudos
Message 11 of 24
(3,639 Views)

This is the link to the 2009 help so it is definitely not obsolete.

 

This is a code example how to use this function.

 

This is a lengthy thread that discusses all kinds of gotchas and wathcouts about the function and also contains some sample code.

 

That is only from the first two pages of the 40 links. I think that should suffice to show you that there IS information, and actually useful too. You just have to read it, digest it and understand it.

Rolf Kalbermatter
My Blog
0 Kudos
Message 12 of 24
(3,636 Views)

Thanks Rolf. Sorry to be a pain. I know very little about C and am struggling to learn about this callback thing as fast as I can. I had studied all the examples in those links, but now I found where PostLVUserEvent is called in the second link. I couldn't figure out how the C code knows anything about PostLVUserEvent, but I found it in extcode.h. I think the "Using External Code in LabVIEW" document will also be useful.

 

George

0 Kudos
Message 13 of 24
(3,624 Views)

________________

LabVIEW does not know pointers and certainly not function pointers. What you should do instead is writing a C DLL that implements the callback and also exports a function to be called by LabVIEW that translates between the callback and a LabVIEW user event.

________________

 

I read this post for LV 8.6. Just wondering if the approach for implementing callback in LV2010 is the same or anything changed?That is write a C DLL that implements callback and export function which can then be called by LabVIEW.

 

*************************************************
CLD
*************************************************
0 Kudos
Message 14 of 24
(3,194 Views)

@lvrat wrote:

I read this post for LV 8.6. Just wondering if the approach for implementing callback in LV2010 is the same or anything changed?That is write a C DLL that implements callback and export function which can then be called by LabVIEW.


There are no changes from 8.6 to 2010 that would allow you to write a callback function in LabVIEW that could be called directly from C.  You'll still need to write at least a minimal C DLL, which either responds directly or calls PostLVUserEvent() to cause LabVIEW to respond.

0 Kudos
Message 15 of 24
(3,182 Views)

 


@lvrat wrote:
 

I read this post for LV 8.6. Just wondering if the approach for implementing callback in LV2010 is the same or anything changed?That is write a C DLL that implements callback and export function which can then be called by LabVIEW.

 


Yes it's still valid and will most likely remain valid for quite some time in the future.

Rolf Kalbermatter
My Blog
Message 16 of 24
(3,180 Views)

Dear Alejandro,

do you solve your problem? And could  you puplish your Solution?

0 Kudos
Message 17 of 24
(1,949 Views)

@HallmannSVS wrote:

Dear Alejandro,

do you solve your problem? And could  you puplish your Solution?


He may have solved it. He probably doesn't read this forum anymore as the last time he logged in here was in September 2011. And even if he would read this post he may not be allowed to share the code as it was probably developed for his employer.

Rolf Kalbermatter
My Blog
0 Kudos
Message 18 of 24
(1,941 Views)

Dear Mr Kalbermatter

do you have an example for a dll within a callback function,and a wrapper dll as a interface for Labview and the dll? of course yes Smiley Happy

are you allowed to share this c-code, VI?

0 Kudos
Message 19 of 24
(1,930 Views)

I don't have a ready made example from actual projects that I could share but there are many poists on this site, some from me too, which detail the process more clearly.

 

http://forums.ni.com/ni/board/crawl_message?board.id=180&message.id=63133

http://forums.ni.com/t5/Example-Program-Drafts/Trigger-a-LabVIEW-User-Event-from-Dynamic-Link-Librar...

http://forums.ni.com/ni/board/crawl_message?board.id=170&message.id=967665

http://digital.ni.com/public.nsf/allkb/89165ede5031c68686257b2e0006fe99

http://forums.ni.com/ni/board/crawl_message?board.id=170&message.id=893812

http://www.ni.com/example/26480/en/

http://lavag.org/topic/15229-how-to-call-postlvuserevent-with-a-cluster-of-scalars-from-c/page__view...

 

It's a lot of information and it's certainly not an easy topic.C function pointers are an advanced programming feature that even many C programmers struggle with. Adding to that the interfacing to an image acquisition library only makes it more daunting. And then LabVIEW which has its very own requirements.

Rolf Kalbermatter
My Blog
0 Kudos
Message 20 of 24
(1,923 Views)