PxMsgEnvelop_EvWait()
Envelops a data area in a newly created message object while waiting for events.
- APPLIES TO
-
1.0.0
- SYNOPSIS
-
PxMsgEvent_t PxMsgEnvelop_EvWait (PxMsgData_t data_area, PxSize_t msgsize, PxOpool_t opoolid, PxEvents_t events); - ARGUMENTS
|
|
|
|
|
|
|
- RETURN VALUES
-
-
The received message handle, or the events, that caused the function to return
-
- ERROR CODES
-
PXERR_OPOOL_ILLOPOOLThe passed object pool handle is invalid
PXERR_OBJ_NOOBJNo free object is available
PXERR_OBJ_ABORTEDThe request was aborted by an event
PXERR_OBJ_ILLOBJThe passed object handle is not valid
PXERR_GLOBAL_ILLEGAL_COREThe requested object pool is not on the same core
PXERR_EVENT_ZEROThe given event mask is 0 for awaiting events
PXERR_PROT_PERMISSIONThe data area is not writable for the calling task
PXERR_MSG_ILL_ALIGNIllegal aligned data pointer
PXERR_MSG_ILLMSGIllegal aligned data pointer
PXERR_MSG_ILL_SIZEIllegal data size
PXERR_INTERNAL_INCONSISTENCYInconsistency of internal structures
- DESCRIPTION
-
The
PxMsgEnvelop_EvWaitfunction envelops a data area specified by arguments data_area (start address) andmsgsize(size in bytes) in a new message object taken from object poolopool. The message object handle is returned. If there is no free object available, thePxMsgEnvelop_EvWaitwaits until a free object is available or until an event from mask of events is signaled.In contrast to normal message object, The newly created envelope message object has implicitly set the await release flag. It is possible to wait for the message object release with function
PxMsgAwaitRelorPxMsgAwaitRel_EvWaitor check the release state by functionPxMsgAwaitRel_NoWait.The task that called
PxMsgEnvelop_EvWaitbecomes the (permanent) owner and the (temporary) user of the created message. The task’s access rights to the data area is marked in the message object and can be read by callingPxMsgGetProtection. The owner may restrict the access right by callingPxMsgSetProtection.
- IMPLEMENTATION GUIDELINES
-
- Before call
-
-
data_areamust be a pointer to a valid data area. -
msgsizemust be a plausible value given as a constant (V) or a variable (C). -
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
-
-
If the message requested with
PxMsgEnvelop_EvWaitis sent to another task, thedata_areamust not be accessed by the requesting task until the recipient releases the message.PxMsgAwaitRelmay be used to await the message’s release.PxMsgEnvelop_EvWaitmay block, if no PXROS-HR object is available and no instance (task or handler) sends an event. If blocking calls are prohibited,PxMsgEnvelop_NoWaitshould be used instead or the call should be monitored by the PXROS-HRPxTomechanism.
-
- SEE ALSO
- USAGE
-
#include "pxdef.h" char Buf[BUFFER_SIZE] PXMEM_ALIGNED; /* The buffer is aligned to 8 bytes */ #define MY_EVENT_MASK 0x1l PxMsgEvent_t msgEvHnd = PxMsgEnvelop_EvWait(Buf, 64, opoolid, MY_EVENT_MASK) if (msgEvHnd.events & MY_EVENT_MASK) { // Handle events } else if (PxMsgIdIsValid (msgEvHnd.msg)) { // Handle returned message } else { // Handle error }