PxMsgGetProtection()

Get protection mode of a message.

APPLIES TO

1.0.0

SYNOPSIS
PxAccessPerm_t PxMsgGetProtection (PxMsg_t msgid);
ARGUMENTS
msgid

Message object for which the protection mode is requested

RETURN VALUES
  • Protection mode (NoAccessProtection, ReadProtection, WriteProtection, WRProtection)

ERROR CODES

PXERR_MSG_ILLMSG

msgid is not a valid object id

PXERR_MSG_ILLUSER

The calling task is not user of this message

DESCRIPTION

PxMsgGetProtection returns the protection mode for the data area of a given message object msgid. The following values are possible:

  • NoAccessProtection the caller has no access to the messages data area

  • ReadProtection the caller has read only access to the messages data area

  • WriteProtection the caller has write only access to the messages data area

  • WRProtection the caller has read and write access to the messages data area

IMPLEMENTATION GUIDELINES
Before call
  • msgid must be a valid message object, requested via PxMsgRequest…​ or PxMsgEnvelop…​ or received by a PxMsgReceive…​ call (V). This id may be checked with one of the following macros:

    • PxMsgIdIsValid() must be true.

    • PxMsgIdGet() must not be _PXIllegalObjId.

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

After call
  • PxMsgGetProtection returns a value of type PxProtectType_t, which may have one of the following values (V):

    • NoAccessProtection neither read nor write access

    • ReadProtection read access

    • WriteProtection write access

    • WRProtection read and write access

Best Practice
  • No restrictions.

SEE ALSO
USAGE
#include "pxdef.h"

PxProtectType_t protType = PxMsgGetProtection(msgid);
switch (protType)
{
case NoAccessProtection:
	// Task has no permission to access message data
	break;
case ReadProtection:
	// Task has read-only permission to access message data
	break;
case WriteProtection:
	// Task has write-only permission to access message data
	break;
case WRProtection:
	// Task has read and write permission to access message data
	break;
}