So I'm porting this C++ program to LabVIEW. I'm a total newbie on Callbacks, and it uses a lot of them (the program gets information from an haptics hardware).
In the original program, there is a function defined as
1 2 3 4 5
|
HDCallbackCode HDCALLBACK updateDeviceCallback(void *pUserData)
{
...blah blah blah...
return HD_CALLBACK_CONTINUE;
}
|
The header defines
1 2 3 4 5
|
/* Return code for callbacks, determines whether the operation is finished
and will unscheduled, or whether it will continue running. */
typedef unsigned int HDCallbackCode;
#define HD_CALLBACK_DONE 0
#define HD_CALLBACK_CONTINUE 1
|
So I ported this function to LabVIEW telling it that the return type is an integer.
But then I need to call it as an argument for another function: in the main loop there is this instruction:
1 2
|
hUpdateHandle = hdScheduleAsynchronous(
updateDeviceCallback, 0, HD_MAX_SCHEDULER_PRIORITY);
|
The API reference defines
1 2 3 4
|
HDSchedulerHandle
hdScheduleAsynchronous(HDSchedulerCallback pCallback,
void *pUserData,
HDushort nPriority)
|
Helios helped me to see that HDSchedulerCallback is a pointer. (
http://www.cplusplus.com/forum/beginner/11576/)
So I don't get it.
1) hdScheduleAsynchronous() expects a HDSchedulerCallback, i.e. a pointer, but the main program is feeding an int function.
2) What's the argument of updateDeviceCallback()? It expects a pointer to void data, but where is it coming from?
I'm sure I'm missing some important concept about Callbacks. From this website I learned perfectly about pointers, but found nothing about callbacks. All I know now is what wikipedia taught me, which is not much. And I'm also getting some help from here:
http://brl.ee.washington.edu/Education/EE589/AIIT/NotesPack/OmniProgramming1.pdf
which turns out to work with the exact same program I'm trying to port to LabVIEW.