OpenClovis Logo

API Usage Examples
Debug Service

Code Examples. More...

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];

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);

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;
}

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