PxMsgRequest_EvWait()
Create a message object together with data area while waiting for events.
- APPLIES TO
-
1.0.0
- SYNOPSIS
-
PxMsgEvent_t PxMsgRequest_EvWait (PxSize_t msgsize, PxMc_t McId, PxOpool_t OpoolId, PxEvents_t events); - ARGUMENTS
|
|
|
|
|
|
|
- RETURN VALUES
-
-
Valid message handle on success
-
Invalid message handle on failure
-
Event mask that caused the call return
-
- 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
PxMsgRequest_EvWaitfunction 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, thePxMsgRequest_EvWaitwaits until a free object is available or until an event from the mask of events occurs.The calling task becomes the (permanent) owner and the (temporary) user of the message created. The call also 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. -
The parameter
eventscontains a bitmask of events awaited and should not be zero. Typically the event mask is a constant (V).
-
- After call
-
-
The returned value is a structure of type
PxMsgEvent_t. The received events are stored in theeventspart, the message id is given in themsgpart of the structure. 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
-
-
PxMsgRequest_EvWaitmay block, if no PXROS-HR object or memory is available and no instance (task or handler) sends an event. If blocking calls are prohibited,PxMsgRequest_NoWait()should be used instead or the call should be monitored by the PXROS-HRPxTomechanism.
-
- SEE ALSO
- USAGE
-
#include "pxdef.h" #define MY_EVENT_MASK 0x1l PxMsgEvent_t msgEvHnd = PxMsgRequest_EvWait(64, McId, OpoolId, MY_EVENT_MASK) if (PxMsgIdIsValid (msgEvHnd.msg)) { /// Request successful - handle message } else if (msgEvHnd.events & MY_EVENT_MASK) { // Request not successful - interrupted by event } else { // Request not successful - check the msgEvHnd.msg.error }