PxSysInfoGetMsgsInMbx()

Get the ids of the messages stored in a mailbox.

APPLIES TO

1.0.0

SYNOPSIS
int PxSysInfoGetMsgsInMbx (PxMbx_t mbxId, PxMsgType_t Type, PxObjId_t *MsgArray, int Max);
ARGUMENTS
mbxId

Mailbox whose messages are counted

Type

Type of messages to be counted

MsgArray

Array to store the message’s id

Max

Maximum number of messages to be counted

RETURN VALUES
  • Number of message ids stored in the array

  • -1 if mbxId is not a valid mailbox or if an inconsistency is detected

DESCRIPTION

PxSysInfoGetMsgsInMbx counts the messages of type Type available in the mailbox mbxId. The message ids are stored in MsgArray until the maximum number of messages, which can be stored in this array, is reached. Max represents this number. The function returns the number of messages in the mailbox, or -1 if mbxId is not a valid mailbox object, or if an inconsistency is detected. Such an inconsistency may occur if messages are received from this mailbox when counting these messages.

IMPLEMENTATION GUIDELINES
Before call
  • MsgArray must be a pointer to a valid data area containing space for Max object ids.

  • The parameter mbxId must be a valid mailbox object id. This id may be

    • the calling task’s own mailbox (V)

    • the return value of a PxTaskGetMbx() call (V)

    • the result of a nameserver query (V)

    • part of a message sent by another task (V)

  • The PXROS-HR message type given in Type must be of type PxMsgType_t and may have one of the following values (V):

    • PXMsgAnyMsg

    • PXMsgNormalMsg

    • PXMsgPrioMsg

After call
  • The function returns -1 if the number of messages in a mailbox could not be determined (C).

Best Practice
  • No restrictions

SEE ALSO
USAGE
#include "pxdef.h"

int num = PxSysInfoGetMsgsInMbx(mbxId, PXMsgNormalMsg, MsgArray, MAX);

if (num == -1) {
    // Report Error
}