PxMsgRequest()
Create a message object together with a data area.
- APPLIES TO
-
1.0.0
- SYNOPSIS
-
PxMsg_t PxMsgRequest (PxSize_t msgsize, PxMc_t McId, PxOpool_t OpoolId); - ARGUMENTS
|
|
|
|
|
- RETURN VALUES
-
-
Valid message handle on success
-
Invalid message handle on failure
-
- ERROR CODES
-
PXERR_OPOOL_ILLOPOOLThe passed object pool handle is invalid
PXERR_MC_ILLMCThe passed memory class handle is invalid
PXERR_MC_NOMEMNot enough memory
PXERR_ACCESS_RIGHTThe calling task has not the right to access the object pool or the memory class
PXERR_GLOBAL_ILLEGAL_COREThe passed memory class is not on the same core
PXERR_OBJ_NOOBJNo free object is available
PXERR_EVENT_ZEROThe given event mask is zero
PXERR_OBJ_ABORTEDRequest aborted by an event
PXERR_OBJ_ILLOBJThe passed object handle is not valid
PXERR_MC_ILLTYPEIllegal MC type
PXERR_MC_SIZETOOBIGFixed block size too small to satisfy the request
PXERR_INIT_ILLMCTYPEThe type for
PXMcSystemdefaultis different fromPXMcVarsized,PXMcVarsizedAdjustedandPXMcVarsizedAlignedPXERR_REQUEST_ABORTEDRequest aborted
PXERR_MC_DAMAGED_BLOCKThe block in the memory class has been damaged
PXERR_MC_INCONSISTENCYInconsistency in memory class:
blkPXERR_MC_ILLSIZEInsufficient block size
PXERR_MC_ILLALIGNInvalid memory block or size alignment in memory insert
PXERR_INTERNAL_INCONSISTENCYInconsistency of internal structures
PXERR_UNSUPPORTED_MCTYPEmc is not supported (If
McIdcorresponds toPXMcVarsized,PXMcVarsizedAligned,PXMcVarsizedAdjusted) - DESCRIPTION
-
The
PxMsgRequestfunction creates a message with a data area of sizemsgsizespecified in byte units. The data area is taken from memory class mc, and the message object is taken from object poolopool. The message object handle is returned. If there is no free object available, thePxMsgRequestwaits until a free object is available.The calling task becomes the (permanent) owner and the (temporary) user of the created message. The call fails, if the memory class does not contain sufficient memory to meet the request. A fatal PXROS error occurs, if mc is
fixsizedand its block size is smaller thanmsgsize. Ifmsgsizeis zero, no data buffer is requested and only the metadata of the message object can be used.
- IMPLEMENTATION GUIDELINES
-
- Before call
-
-
msgsizemust be a plausible value given as a constant (V) or a variable (C). -
McIdmust be a valid PXROS-HR memory class and the calling task must have the access right to take memory from this memory class (V). The validity ofMcIdmay also be checked by thePxMcIsValidmacro (F). The memory class must be created on the same core as the caller runs on. The creator core id can be read with the macroPxMcCoreIdand the own core id withPxGetCoreId(C). Typically the task’s default memory classPXMcTaskdefaultis used for this purpose. -
OpoolIdmust be a valid PXROS-HR object pool and the calling task must have the access right to take objects from this object pool (V). The validity ofOpoolIdmay also be checked by thePxOpoolIsValidmacro (F). The object pool must be created on the same core as the caller runs on. The creator core id can be read with the macroPxOpoolCoreIdand the own core id withPxGetCoreId(C). Typically the task’s default object poolPXOpoolTaskdefaultis used for this purpose.
-
- After call
-
-
The returned value is the id of type
PxMsg_t. This id may be checked with one of the following macros:-
PxMsgIdIsValid()must be true. -
PxMsgIdGet()must not be_PXIllegalObjId. -
PxMsgIdError()must bePXERR_NOERRORotherwise the returned error code has to be interpreted (C).
-
-
- Best Practice
-
-
PxMsgRequestmay block, if no PXROS-HR object or memory is available. If blocking calls are prohibited,PxMsgRequest_NoWait()should be used instead.
-
- SEE ALSO
- USAGE
-
#include "pxdef.h" PxMsg_t msgHnd = PxMsgRequest (64, McId, OpoolId) if (!PxMsgIdIsValid (msgHnd)) { // Report error; }