Skip to main content

NRC_SetMsgHappenCallback(void (*fun)(void))

Set the callback function to be called when the message occurs

When a message occurs, this callback function will be called

Type

int =>Set the callback function to be called when the message occurs

Return valueDescription
0The function is called successfully
-101Invalid input parameter
-102The target object does not exist. This typically occurs when the system initialization is incomplete, and calling other functions may return this value
-103The target object is currently in an inoperable state

Parameter Option

ParameterTypeDescription
*funvoidFunction pointer of the callback function

Sample code

void msgHook()
{
NRC_Messsage tmp;//Define a message structure object
NRC_GetMesssage(1, tmp);//Assign the earliest message in the message queue to the object "tmp"
printf("msgHooklocalTime=%d:%d::%d,0x%x,0x%x,text=%s,size=%d\n",tmp.localTime.minute, tmp.localTime.second, tmp.localTime.milliseconds, tmp.kind, tmp.code, tmp.text.c_str(),NRC_GetMesssageSize());
}
NRC_SetMsgHappenCallback(msgHook);//Set the callback function to be called when the message occurs