LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

pass data back through the (void*)callback

I'd like to pass data back through the (void*) callback data variable to the calling function without using global variables.  Could you please show me sample code which assigns a value to the *callback data  (within the callback) thus allowing it to be passed back to the calling function
0 Kudos
Message 1 of 3
(3,501 Views)
Hi ray123,
 
Check out the Using the void *callbackData Parameter in Callback Functions KnowledgeBase and the Callback Data Example in CVI example for help. Basically you will be using the SetCtrlAttribute function with the ATTR_CALLBACK_DATA attribute which will allow you to assign the callback data pointer to some user data.
 
Hope this helps!
 
Best Regards,
Jonathan N.
National Instruments
Message 2 of 3
(3,492 Views)
I often use it to pass single integers without using pointer logic.

In the calling code:
PostDeferredCall(cb_ReceivedControl, (void*)(Card<<8 | usbData[0]));

In the receiving code:
static void CVICALLBACK cb_ReceivedControl(void *callbackData) {
int Card=(int)callbackData>>8;
char Data=(int)callbackData&0xFF;
....}

--
Guillaume Dargaud
http://www.gdargaud.net/


Message 3 of 3
(3,481 Views)