From: lmd2 on
Hi Rolf
may I change the subject for a moment and ask you another question?
I have another function with 4 inputs, DevNum, Enable, IRQ Mask, and a pointer to a user defined function.
 
The user sets the IRQ mask, and if a defined interrupt occurrs, the user function gets called; the prototype looks like:
S16BIT _DEC aceSetIrqConditions(S16BIT DevNum, U16BIT bEnable, U32BIT dwIrqMask,
                void(_DEC *funcExternallsr)(S16BIT DevNum, U32BIT dwIrqStatus));
 
How do I configure a function's input to accept a pointer to another function?
thanx
From: Jared_B on
Rolf, So you would then recommend allocating the memory for the Array in the wrapper DLL.  Passing the pointer to that memory location back to LabVIEW as a uInt32, and getting the data from that memory location with the MoveBlock?
From: rolfk on
Jared_B wrote:Rolf,So you would then recommend allocating the memory for the Array in the wrapper DLL.  Passing the pointer to that memory location back to LabVIEW as a uInt32, and getting the data from that memory location with the MoveBlock?That's the more simple solution. You do not strictly need a DLL wrapper since you can also call DSNewPtr in the same way as MoveBlock directly from LabVIEW (and of course don't forget to call DSDisposePtr at the end).The more sleazy way is to construct a pointer to a pointer with an extra DSNewPtr that allocates a 4 byte memory block, then copies the contents of the first buffer pointer into it and then passes the reference to that 4 byte buffer as pointer to the real pointer to the function in question. Needs some pointer brain exercise to get it right but avoids the performance overhead of having to copy the data repeatedly out of the buffer after each call.Rolf Kalbermatter
From: rolfk on
lmd2 wrote:
Hi Rolf
may I change the subject for a moment and ask you another question?
I have another function with 4 inputs, DevNum, Enable, IRQ Mask, and a pointer to a user defined function.
 
The user sets the IRQ mask, and if a defined interrupt occurrs, the user function gets called; the prototype looks like:
S16BIT _DEC aceSetIrqConditions(S16BIT DevNum, U16BIT bEnable, U32BIT dwIrqMask,
                void(_DEC *funcExternallsr)(S16BIT DevNum, U32BIT dwIrqStatus));
 
How do I configure a function's input to accept a pointer to another function?
thanxI've written elsewhere here already several times about this. And the answer is you basically don't and can't!You have to bite the bullet and write a wrapper DLL that provides that callback function pointer and in there you translate that event into a more LabVIEW user friendly event. If you do not have any data to send back to LabVIEW with the event you can translate it in an occurrence.Otherwise you need to translate it into a LabVIEW user event using the LabVIEW exported function PostLVUserEvent(). There are samples here on the NI site if you look for that name in the search.Rolf KalbermatterMessage Edited by rolfk on 07-09-2008 11:44 PM
From: lmd2 on
Thanks Rolf,
when I read "write a wrapper DLL that provides that callback function pointer and in there you translate that event into a more LabVIEW user friendly event" it just confused me even more. I understand LabVIEW and occurances and user events; but not DLLs.
What would have made this a lot clearer (to me at least) would be to say that the input to the client's DLL (where a pointer to a user function) is expected will be wired to an user event refnum with type = adapt to type, and Data Format = Handles by Value.
The LabVIEW side of this is very straight forward to me, but keeping the client's DLL happy is where you keep losing me.
even your earlier posting:
<a href="http://forums.ni.com/ni/board/message?board.id=170&amp;thread.id=88974&amp;view=by_date_ascending&amp;page=1" target="_blank">http://forums.ni.com/ni/board/message?board.id=170&amp;thread.id=88974&amp;view=by_date_ascending&amp;page=1</a>
didn't help until I saw the uservevent.zip example that you attached (a picture really is worth a thousand words)
thanks again
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10
Prev: error 200279
Next: CMD.EXE Output Not Showing up