The Command Interpreter provides structures and functions for parsing incoming messages.
Features:
The application provides a MessageId Table which contains all supported MessageIds together with their belonging handler functions. The MessageId Table is an array of Ucs_Cmd_MsgId_t elements. Each element contains a MessageId (0x0000 .. 0xFFFE) and a pointer to the belonging handler function. The table ends with the termination entry {UCS_CMD_MSGID_TERMINATION, NULL}.
The application announces the MessageId Table with the function Ucs_Cmd_AddMsgIdTable(). The connection to the MessageId Table can be removed with the function Ucs_Cmd_RemoveMsgIdTable().
A received message is given to Ucs_Cmd_DecodeMsg(). This function retrieves the MessageId from the message and calls the belonging handler function. The handler function can return three values:
Value | Description |
---|---|
UCS_CMD_RET_SUCCESS | The handler function succeeded. |
UCS_CMD_RET_ERR_TX_BUSY | The handler function could not send an answer because no free Tx Buffer was available. |
UCS_CMD_RET_ERR_APPL | An error happened in handler function. |
The following code example shows how the Command Interpreter API function can be used: