Error related
3.7.1 Pop up messages in the queue
Call the function NRC_Messsage NRC_FirstMesssagePop()
to pop up the earliest message in the message queue. Get the earliest message in the queue, remove the message from the queue, and return the earliest message in the queue.
Call the function NRC_Messsage NRC_LastMesssagePop()
to pop up the last message in the message queue. Get the last message in the queue, remove the message from the queue, and return the last message in the queue.
Call the function NRC_GetMesssage(int num, NRC_Messsage& msg)
to get the num-th message in the queue. This function gets the num-th message in the queue, and will not remove the message. The parameter num refers to the number of the message to be obtained in the queue, the earliest message number is 1, and the value range is: 0 < num <= NRC_GetMesssageSize(). The obtained message is returned through the parameter msg.
Call the function NRC_GetMesssageSize()
to get the total number of messages in the queue.
Call the function NRC_ClearMesssage()
to clear the message queue.
Note: The user-defined range is after 0x9000. The member "type" has been removed from the message structure, and two new members have been added: "code" for message encode and "robot" for robot number. The message data structure is as follows:
struct NRC_Messsage
{
NRC_TIME localTime;///<System time when the message was generated
int kind; ///<Message level: 0: general message, 1: warning message, 2: error message, 3: important message
int code;///<Message code
int robot;///<Robot number
std::vector<int> param;//<Message content parameters, the number varies depending on the specific encoding, a total of 5 are reserved
std::string text;///<Message content
};
3.7.2 Callback function
Set the callback function NRC_SetMsgHappenCallback(void (*fun)(void))
to be called when the message occurs. This callback function will be called when the message occurs. "fun" is the function pointer of the callback function.
The following is a sample program (partial) used by the above interface
..........
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,0x%x,text=%s,size=%d\n",tmp.localTime.minute,tmp.localTime.second,tmp.localTime.milliseconds,tmp.kind,tmp.code,tmp.robot,tmp.text.c_str(),NRC_GetMesssageSize());
}
...........
NRC_SetMsgHappenCallback(msgHook);//Set the callback function to be called when the message occurs
...........
3.73.3 Clear error
Call the function NRC_ClearServoError()
to clear the servo error. It should be noted that not all servo errors can be cleared directly, some errors need to be diagnosed and resolved before they can be cleared.
Call the function NRC_ClearAllError()
to clear all errors, including clearing the message queue and clearing servo errors. However, it should be noted that not all servo errors can be cleared directly, and some errors need to be diagnosed and resolved before they can be cleared.
The time data structure is as follows:
struct NRC_TIME
{
int year;
int month;
int day;
int hour;
int minute;
int second;
int milliseconds;
};