PxMbxRequest_EvWait()

Request a mailbox object while waiting for events.

APPLIES TO

8.2.0

SYNOPSIS
PxMbx_t PxMbxRequest_EvWait (PxOpool_t opoolid, PxEvents_t events);
ARGUMENTS
events

Eventmask that makes the call return

opoolid

The object pool, where the mailbox object is requested from

RETURN VALUES
  • Invalid mailbox object handle on failure

  • Valid mailbox object handle on success

ERROR CODES

PXERR_ACCESS_RIGHT

The calling task has not the right to access the object pool

PXERR_OPOOL_ILLOPOOL

opoolid is not a valid object pool

PXERR_OBJ_ABORTED

Request aborted by an event

PXERR_MBX_ILLMBX

Invalid mailbox in mailbox command

PXERR_EVENT_ZERO

The given event mask is zero

PXERR_GLOBAL_ILLEGAL_CORE

The requested object pool is not on the same core

PXERR_OBJ_NOOBJ

No free object is available

PXERR_OBJ_ILLOBJ

The passed object handle is not valid

PXERR_INTERNAL_INCONSISTENCY

Inconsistency of internal structures

DESCRIPTION

The PxMbxRequest_EvWait function creates a mailbox object by converting a free object from object pool opool. The object handle is returned. If there is no free object available, PxMbxRequest_EvWait waits until either there is a free object or an event specified in the set events occurs.

IMPLEMENTATION GUIDELINES
Before call
  • opoolid must 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 of opoolid may also be checked by the PxOpoolIsValid macro (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 macro PxOpoolCoreId and the own core id with PxGetCoreId (C). Typically the task’s default object pool PXOpoolTaskdefault is used for this purpose.

  • 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 PxMbxEvent_t. The received events are stored in the events part, the mailbox id is given in the mbx part of the structure. This id may be checked with one of the following macros:

    • PxMbxIdIsValid() must be true.

    • PxMbxIdGet() must not be _PXIllegalObjId.

    • PxMbxIdError() must be PXERR_NOERROR otherwise the returned error code has to be interpreted (C).

Best Practice
  • PxMbxRequest_EvWait may block, if no PXROS-HR object is available and no instance (task or handler) sends an event. If blocking calls are prohibited, PxMbxRequest_NoWait should be used instead or the call should be monitored by the PXROS-HR PxTo mechanism.

  • PxMbxRequest_EvWait should only be called during initialization to ensure the availability of the mailbox object.

SEE ALSO
USAGE
#include "pxdef.h"

#define MY_EVENT_MASK 0x1l

PxMbx_t Mbx = PxMbxRequest_EvWait(opoolid, MY_EVENT_MASK);

if (PxMbxIdError(Mbx) != PXERR_NOERROR) {
    // Report error
}