OpenClovis Logo

Code Examples.

Code Examples.

Marshall the data, array and pointer of type ClUint8T

ClRcT rc = CL_OK;
ClBufferHandleT inMsgHdl = 0;
ClBufferHandleT outMsgHdl = 0;
ClUint8T uint8Data = 120;
ClUint8T uint8Arr[10] = {0};
ClUint8T *uint8Ptr = NULL;
ClUint32T i = 0;
ClUint32T funcNo = CL_EO_GET_FULL_FN_NUM
ClUint32T rmdFlags = 0;
ClIocAddressT address = {{0}};
/*Allocate Pointer*/
uint8Ptr = (ClUint8T*)clHeapAllocate (10*sizeof(ClUint8T));
if(NULL != uint8Ptr)
{
clLogError("EXP","XDR", "Memory allocation Failed.");
}
for(i = 0; i < 10; i++)
{
uint8Arr[i] = i;
uint8Ptr[i] = 10 - i;
}
/*inMsgHdl buffer create*/
rc = clBufferCreate(&inMsgHdl);
if(rc != CL_OK)
{
clLogError("EXP","XDR", "Buffer creation Failed.");
return rc;
}
/* Marshall ClUint8T data */
rc = clXdrMarshallClUint8T(&uint8Data, inMsgHdl, 0);
if(rc != CL_OK)
{
clLogError("EXP","XDR", "Marshalling of ClUint8T data Failed.");
return rc;
}
/*Marshall ClUint8T array*/
rc = clXdrMarshallArrayClUint8T(uint8Arr, sizeof(uint8Arr) /
sizeof(ClUint8T), inMsgHdl, 0);
if(rc != CL_OK)
{
clLogError("EXP","XDR", "Marshalling of ClUint8T array Failed.");
return rc;
}
/*Marshall ClUint8T ptr*/
rc = clXdrMarshallPtrClUint8T(uint8Ptr, 10, inMsgHdl, 1);
if(rc != CL_OK)
{
clLogError("EXP","XDR", "Marshalling of ClUint8T pointer Failed.");
return rc;
}
rmdFlags &= ~CL_RMD_CALL_ASYNC;
address.iocPhyAddress.portId = /*Fill this with the appropriate port id
for rmd call*/
/*Master Addr get*/
if(rc != CL_OK)
{
clLogError("EXP","XDR", "Failed to get master address.");
return rc;
}
/*outMsgHdl buffer create*/
rc = clBufferCreate(&outMsgHdl);
if(rc != CL_OK)
{
clLogError("EXP","XDR", "Buffer creation Failed.");
return rc;
}
/*RMD for ClUint8T*/
rc = clRmdWithMsg(address, funcNo, inMsgHdl, outMsgHdl,
rmdFlags, &rmdOptions, NULL);
if(rc != CL_OK)
{
clLogError("EXP","XDR", "Rmd call Failed.");
return rc;
}
clBufferDelete(&outMsgHdl);
ClPtrT ClBufferHandleT
The type of the handle for the buffer messages.
Definition: clBufferApi.h:82
ClRcT clBufferDelete(ClBufferHandleT *pMessageHandle)
Deletes the Buffers.
ClRcT clBufferCreate(ClBufferHandleT *pMessageHandle)
Creates a new message.
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
#define CL_ERR_NO_MEMORY
Memory is not available.
Definition: clCommonErrors.h:73
#define CL_OK
Every thing is OK.
Definition: clCommonErrors.h:68
ClRcT clCpmMasterAddressGet(CL_OUT ClIocNodeAddressT *pIocAddress)
Returns the IOC address of the master.
#define CL_EO_GET_FULL_FN_NUM(cl, fn)
Defines a mechanism to generate unique RMD function number for the function.
Definition: clEoApi.h:189
@ CL_EO_NATIVE_COMPONENT_TABLE_ID
This is the service provided by Host EO.
Definition: clEoApi.h:211
ClPtrT clHeapAllocate(CL_IN ClUint32T size)
Allocates memory of the requested size.
#define CL_RMD_DEFAULT_OPTIONS
Default values for the options.
Definition: clRmdApi.h:135
#define CL_RMD_CALL_NON_PERSISTENT
0x0010 If you want RMD to use and free its input message, you are required to set this bit to 1.
Definition: clRmdApi.h:86
#define CL_RMD_CALL_ASYNC
0x0001 If you want to make a synchronous call, set this bit to 0.
Definition: clRmdApi.h:66
#define CL_RMD_CALL_NEED_REPLY
0x0002 If you do not require to check the reply, set this bit to 0.
Definition: clRmdApi.h:71
ClRcT clRmdWithMsg(CL_IN ClIocAddressT remoteObjAddr, CL_IN ClUint32T funcId, CL_IN ClBufferHandleT inMsgHdl, CL_OUT ClBufferHandleT outMsgHdl, CL_IN ClUint32T flags, CL_IN ClRmdOptionsT *pOptions, CL_IN ClRmdAsyncOptionsT *pAsyncOptions)
Invokes a Remote Function Call when the parameters are passed as messages.
ClRcT clXdrMarshallClUint8T(CL_IN void *pPyld, CL_INOUT ClBufferHandleT msg, CL_IN ClUint32T isDelete)
Marshall data of ClUint8T type.
ClRcT clXdrMarshallPtrClUint8T(void *pPyld, ClUint32T count, ClBufferHandleT msg, ClUint32T isDelete)
Marshall pointer of ClUint8T type.
ClRcT clXdrMarshallArrayClUint8T(void *pPyld, ClUint32T count, ClBufferHandleT msg, ClUint32T isDelete)
Marshall array of ClUint8T type.
ClIocPortT portId
The IOC communication end point identification on a node.
Definition: clIocApi.h:393
ClIocNodeAddressT nodeAddress
The IOC Node address.
Definition: clIocApi.h:388
IOC address.
Definition: clIocApi.h:401
ClIocPhysicalAddressT iocPhyAddress
Physical address.
Definition: clIocApi.h:406
This is a structure to pass optional parameters.
Definition: clRmdApi.h:196

Unmarshall the data, array and pointer of type ClUint8T

/*Get the in-message-handle 'inMsgHdl' and out-message-handle 'outMsgHdl'
from RMD receieve function. */
ClRcT rc = CL_OK;
ClUint8T recvData = 0;
ClUint8T recvArr[10] = {0};
ClUint8T *recvPtr = NULL;
/*Unmarshall data, it will get stored in recvData*/
rc = clXdrUnmarshallClUint8T(inMsgHdl, &recvData);
if(rc != CL_OK)
{
clLogError("EXP","XDR", "Unmarshalling of Uint8T data Failed.");
return rc;
}
/*Unmarshall 10 array elements, it will get stored in recvArr*/
rc = clXdrUnmarshallArrayClUint8T(inMsgHdl, &recvArr, 10);
if(rc != CL_OK)
{
clLogError("EXP","XDR", "Unmarshalling of Uint8T array Failed.");
return rc;
}
/*Unmarshall 10 elements of type ClUint8T, it will get stored in recvPtr*/
rc = clXdrUnmarshallPtrClUint8T(inMsgHdl, (void**)&recvPtr, 10);
if(rc != CL_OK)
{
clLogError("EXP","XDR", "Unmarshalling of Uint8T pointer Failed.");
return rc;
}
if(rc == CL_OK)
{
/*Free the pointer allocated in clXdrUnmarshallPtrClUint8T()*/
clHeapFree(recvPtr);
}
void clHeapFree(CL_IN ClPtrT pAddress)
Frees a pre-allocated memory.
ClRcT clXdrUnmarshallPtrClUint8T(ClBufferHandleT msg, void **pPyld, ClUint32T multiplicity)
Unmarshall data of ClUint8T pointer type.
ClRcT clXdrUnmarshallClUint8T(ClBufferHandleT msg, void *pPyld)
Unmarshall data of ClUint8T type.
ClRcT clXdrUnmarshallArrayClUint8T(ClBufferHandleT msg, void *pPyld, ClUint32T count)
Unmarshall data of ClUint8T array type.

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