PxMsgReceive_EvWait()
Receive a message from a mailbox while waiting for events.
- APPLIES TO
-
8.2.0
- SYNOPSIS
-
PxMsgEvent_t PxMsgReceive_EvWait (PxMbx_t mbxid, PxEvents_t events); - ARGUMENTS
|
|
|
- RETURN VALUES
-
-
The received message handle and/or the received events
-
- ERROR CODES
-
PXERR_MBX_ILLMBXThe passed mailbox handle is invalid
PXERR_MSG_NOMSGNo message available
PXERR_MSG_ILLMSGThe passed message handle is invalid
PXERR_MSG_ILLUSERThe calling task is not the user of the message
PXERR_EVENT_ZEROThe given event mask is zero
- DESCRIPTION
-
PxMsgReceive_EvWaitreceives a message object from mailboxmbxidand returns the received message handle. The task becomes the user of the received message. If there is no message in the mailboxmbxid, thePxMsgReceive_EvWaitwaits until a message arrives or until an event from mask of events is signaled.
- IMPLEMENTATION GUIDELINES
-
- Before call
-
-
The parameter
mbxidmust be a valid mailbox object id. This id may be-
the calling task’s own mailbox (V)
-
the result of a
nameserverquery (V) -
part of a message sent by another task (V)
-
-
The mailbox may be checked with the macros
-
PxMsgIdIsValid()must be true. -
PxMsgIdGet()must not be_PXIllegalObjId. -
PxMsgIdError()must bePXERR_NOERRORotherwise the returned error code has to be interpreted (C).
-
-
or with a call of
PxMbxCheck()(C). -
The mailbox
mbxmust be created on the same core as the caller runs on. The creator core id can be read with the macroPxMbxCoreIdand the own core id withPxGetCoreId(C). -
The parameter events contains 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, if a message is taken from the mailbox. 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
-
-
PxMsgReceive_EvWaitmay block, if no message is available at the mailbox and no instance (task or handler) sends an event. If blocking calls are prohibited,PxMsgReceive_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 = PxMsgReceive_EvWait(mbxid, 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 }