OpenClovis Logo

API Usage Examples

Code Examples.

Code Examples.

The following structure describes about the function:

typedef struct ClDebugFuncEntry {
ClDebugCallbackT callback;
ClCharT funcName[CL_DEBUG_FUNC_NAME_LENGTH];
ClCharT funcHelp[CL_DEBUG_FUNC_HELP_LENGTH];
ClRcT(* ClDebugCallbackT)(ClUint32T argc, ClCharT **argv, ClCharT **ret)
This is the signature of the callback invoked by the debug CLI in response to a command entered.
Definition: clDebugApi.h:249
struct ClDebugFuncEntryT ClDebugFuncEntryT
The structure contains the entry for the debug CLI information that needs the component has to provid...

When the component registers with the debug gateway, the gateway becomes aware of the component. Thus when the user requests for a list of available components, all registered components are displayed. When the component comes up, it registers its debug APIs with the debug object. This API is as follows:

typedef struct ClDebugModEntry {
ClCharT modName[80];
ClCharT modPrompt[20];
ClCharT help[80];
struct clEoExecutionObj* pEoObj,
ClCharT* compName,
ClCharT* compPrompt,
ClDebugFuncEntryT* funcArray,
ClUint32T funcArrayLen);
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
struct ClDebugModEntryT ClDebugModEntryT
This structure is used to register the module with the CLI library.
ClRcT clDebugRegister(CL_IN ClDebugFuncEntryT *funcArray, CL_IN ClUint32T funcArrayLen, CL_OUT ClHandleT *phDebugReg)
Registers the component name.
The structure contains the entry for the debug CLI information that needs the component has to provid...
Definition: clDebugApi.h:270

This is called on a per instance basis. This makes the debug object in the EO aware of the debug capabilities of the installed component. There are corresponding deregister functions provided for both the functions above.

Following are the example of how to register commands with the CLI framework:

/*Function which executes command one with name 'clDbgCmd1'*/
static ClRcT
clDbgCmd1Func(int argc, char **argv, ClCharT **ret)
{
ClRcT rc = CL_OK;
/*Print handle initialize*/
if(rc != CL_OK)
{
clLogError("EXP","DBG", "Debug print init Failed.");
return rc;
}
if(2 != argc)
{
/*Debug Print*/
rc = clDebugPrint(msg,
"\bUsage: clDbgCmd1 <Your Name>\n");
if(rc != CL_OK)
{
clLogError("EXP","DBG", "Debug print Failed.");
return rc;
}
}
/*Debug Print*/
rc = clDebugPrint(msg, "\nHello %s !", argv[1]);
if(rc != CL_OK)
{
clLogError("EXP","DBG", "Debug print Failed.");
return rc;
}
/*Dbg Print Finalize*/
rc = clDebugPrintFinalize(&msg, ret);
if(rc != CL_OK)
{
clLogError("EXP","DBG", "Debug print finalize Failed.");
return rc;
}
return rc;
}
/*Function which executes command two with name 'clDbgCmd2'*/
static ClRcT
clDbgCmd2Func(int argc, char **argv, ClCharT **ret)
{
ClRcT rc = CL_OK;
ClUint32T id = 0;
/*Print handle initialize*/
if(rc != CL_OK)
{
clLogError("EXP","DBG", "Debug print init Failed.");
return rc;
}
if(3 != argc)
{
/*Debug Print*/
rc = clDebugPrint(msg,
"\bUsage: clDbgCmd2 <Your Name> <Your ID>\n");
if(rc != CL_OK)
{
clLogError("EXP","DBG", "Debug print Failed.");
return rc;
}
}
id = atoi(argv[2]);
/*Debug Print*/
rc = clDebugPrint(msg, "\nHello [%s], your ID is [%d]\n",
argv[1], id);
if(rc != CL_OK)
{
clLogError("EXP","DBG", "Debug print Failed.");
return rc;
}
/*Dbg Print Finalize*/
rc = clDebugPrintFinalize(&msg, ret);
if(rc != CL_OK)
{
clLogError("EXP","DBG", "Debug print finalize Failed.");
return rc;
}
return rc;
}
/* Info about the Commands to be registered */
static ClDebugFuncEntryT clRegisterCmdFuncs[] = {
{
(ClDebugCallbackT) clDbgCmd1Func,/* Function to be called when
command 'clDbgCmd' is executed */
"clDbgCmd1", /* Command */
"DebugCommand : One" /* Help */
},
{
(ClDebugCallbackT) clDbgCmd2Func,/* Function to be called when
command 'clDbgCmd2' is executed */
"clDbgCmd2", /* Command */
"DebugCommand : Two" /* Help */
}
};
/*Code to register commands 'clDbgCmd1' and 'clDbgCmd2'*/
ClRcT rc = CL_OK;
ClHandleT clDbgHdl = CL_HANDLE_INVALID_VALUE;
rc = clDebugRegister(RegisterCmdFuncs,
sizeof(clRegisterCmdFuncs) /
sizeof(clRegisterCmdFuncs[0]),
&clDbgHdl)) == CL_OK,
if(rc != CL_OK)
{
clLogError("EXP","DBG", "Command registration Failed.");
return rc;
}
#define CL_OK
Every thing is OK.
Definition: clCommonErrors.h:68
ClRcT clDebugPrint(CL_INOUT ClDebugPrintHandleT msg, CL_IN const char *fmtStr,...) CL_PRINTF_FORMAT(2
Prints a string into the handle.
ClRcT clDebugPrintInitialize(CL_OUT ClDebugPrintHandleT *msg)
Retrieve a handle for printing.
ClRcT ClRcT clDebugPrintFinalize(CL_IN ClDebugPrintHandleT *msg, CL_OUT char **buf)
Cleans up the print handle.
ClPtrT ClDebugPrintHandleT
The type of the handle clDebugPrint APIs.
Definition: clDebugApi.h:312
#define CL_HANDLE_INVALID_VALUE
Defines.
Definition: clHandleApi.h:95

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen