bilancata Posted September 7, 2005 Report Share Posted September 7, 2005 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 ? If you have further questions please don't hesitate to contact me.... Quote Link to comment
Mike Ashe Posted December 5, 2005 Report Share Posted December 5, 2005 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.