passing a pointer to a stack variable to a mailbox

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • passing a pointer to a stack variable to a mailbox

    Hi

    Would there a be problem calling OS_PutMail for a multi byte message, passing it a pointer to a temporary stack variable, for example:

    void aFunction(void)
    {
    short int aMsg = 12345678;

    OS_PutMail(&aMB, &aMsg);
    }

    Thanks
    Lawrence
  • Hi,

    No problem, you may use local variables to pass data via mailbox.
    The mailbox stores the data and not the pointer to the data.
    When calling OS_PutMail(), the data which is pointed to by the data pointer is copied into the mailbox buffer, before the OS_PutMail() function is left.

    Regards,
    Armin