OS_GetMailCond1 question

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

  • OS_GetMailCond1 question

    I'm using OS_GetMailCond1 as such

    if (OS_GetMailCond1(&mb,&key))
    process(key);

    But it seems that this is no good since the data is left in the mail box buffer.

    I experimented by using OS_PutMailCond1(&mb,&c) only once, but the process key would run forever.

    Does OS_GetMailCond1 not clear the buffer automatically? Am I over simplifying this?

    I went to

    if(OS_GetMessageCnt(&mb))
    {
    OS_GetMailCond1(&mb,&key))
    process(key);
    }

    And that seems to work. But, I don't understand the operation of OS_GetMailCond1(&mb,&key) returning success if the result of OS_GetMessageCnt(&mb) is zero.

    Am I making a bad assumption or is something wrong?
  • I guess you made a simple mistake.

    The return values of OS_GetMailCond1() are:

    Return value
    0: Success; message retrieved.
    1: Message could not be retrieved (mailbox is empty); destination remains
    unchanged.

    Therefore (OS_GetMailCond1(&mb,&key)) is true when the mailbox is empty.

    This should be the right code:

    if (OS_GetMailCond1(&mb,&key) == 0) {
    process(key);
    }
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.