Jump to content

Function Handler in LabVIEW


Recommended Posts

Hi guys,

I need to know if is possible, how to obtain a the handler of a callback function written in a C source file which further to be passed as an input parameter to a VI. This VI registers the handler for a function that will call the callabck function when a message is received on the serial channel.

Please find below a small example of how these functions are used in C based applicaitons:

void CallbackFunction(WORD variable1, WORD variable2, long value)

{

if(variable1 == EXAMPLE_AXIS_ID_001 && variable2 == SRL_ADDRESS)

{

printf("The value is: %ld [long]\n", value);

}

}

void main()

{

RegisterHandler( &CallbackFunction ); // function from DLL file made by me

while(1)

{

CheckForMessages(); // function from DLL made by me

}

return 0;

}

/*-------- the end of example---------*/

the function prototype is the following:

#ifdef WIN32

typedef void (__stdcall *pfnCallbackRecvDriveMsg)(WORD wAxisID, WORD wAddress, long Value);

#else

typedef void (*pfnCallbackRecvDriveMsg)(WORD wAxisID, WORD wAddress, long Value);

#endif

void TML_EXPORT RegisterHandler(pfnCallbackRecvDriveMsg handler);

/*******************************************************************************************

Function: Register application's handler.

Input arguments:

pfnCallbackRecvDriveMsg: pointer to handler

Output arguments:

*******************************************************************************************/

BOOL TML_EXPORT CheckForUnrequestedDriveMessages();

/*******************************************************************************************

Function: Check if there are new messages and call handler for every message received.

Input arguments:

Output arguments:

return: TRUE if no error; FALSE if error

*******************************************************************************************/

Is possibel to use the CIN option and how ? :unsure:

If you have further questions please don't hesitate to contact me....

Link to comment
  • 2 months later...

Probably the easiest way to get this into LabVIEW use (under Windows at least) is to incorporate your code into ActiveX or .NET then use events from those. LabVIEW now has the ability to hook onto callbacks from them. Search NI DevZone for articles on examples of how to do this.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.