PxMsgReceive()
Receive a message from a mailbox.
- APPLIES TO
-
1.0.0
- SYNOPSIS
-
PxMsg_t PxMsgReceive (PxMbx_t mbxid); - ARGUMENTS
|
- RETURN VALUES
-
-
The received message handle
-
- 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
-
PxMsgReceivereceives 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, thePxMsgReceivewaits until a message arrives.
- 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).
-
- 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
-
-
PxMsgReceivemay block, if no message is available at the mailbox. If blocking calls are prohibited,PxMsgReceive_NoWaitshould be used instead.
-
- SEE ALSO
- USAGE
-
#include "pxdef.h" PxMsg_t Msg = PxMsgReceive(mbxid); if (!PxMsgIdIsValid(Msg)) { // Report error }