This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Mailbox (notEmptyEvent)

I'm trying to implement a mailbox with an associated event as explained on page 116 in the User's guide (v6.34) but CCS is complaining that the notEmptyEvent parameter does not exist.

I'm using SSY/BIOS V 6.34.2.18.

Any ideas?

  • Andrew,

    This is a known bug in the GUI configuration tool and is slated to be fixed in the 6.35.02 release due out in late June.

    In the meantime, you can create the Mailbox and Event objects using the GUI tool, and then plug the Event objects into the Mailbox by manually editing the script file.

    For instance, if the Mailbox instance is named "mailbox0" and the two event objects are named "event0" and "event1", you can then manually edit the generated script for the Mailbox.create() by setting the readerEvent and writerEvent as below:

      var mailbox0Params = new Mailbox.Params();
      mailbox0Params.instance.name = "mailbox0";
      mailbox0Params.readerEvent = Program.global.event0; /* manually added line */
      mailbox0Params.writerEvent = Program.global.event1; /* manually added line */
      Program.global.mailbox0 = Mailbox.create(8, 8, mailbox0Params);

    Remember that in order for Mailbox (and Semaphore) objects to support internal Event objects, you must enable this feature by setting the Semaphore.supportsEvents config parameter to 'true'. This can be done in the GUI tool or by manually adding the following line to the configuration script:

     Semaphore.supportsEvents = true;

    Alan

  • I've gotten past pending on a event linked to a mailbox post.  The event gets triggered and the event flag assigned for mail is set,  but now I'm having trouble reading the mail message.  Stepping into the Mailbox_pend call shows

    Bool Mailbox_pend(Mailbox_Object *obj, Ptr msg, UInt timeout)
    {
        Mailbox_MbxElem *elem;
        Queue_Handle dataQue;
        Queue_Handle freeQue;
        Semaphore_Handle dataSem, freeSem;
        UInt key;

        dataQue = Mailbox_Instance_State_dataQue(obj);
        freeQue = Mailbox_Instance_State_freeQue(obj);
        dataSem = Mailbox_Instance_State_dataSem(obj);
        freeSem = Mailbox_Instance_State_freeSem(obj);

        if (Semaphore_pend(dataSem, timeout)) {
            /* get message from dataQue */
            elem = Queue_get(dataQue);

    now the Semaphore_pend fails so I can't get to the message.  What exactly is going on here? Do I need a semaphore associated with the event?  I can't find any documentation that would tell me so.

  • The Semaphores used by the Mailbox APIs are used internally and automatically created when the Mailbox is created.

    Can you share a snippet of the application code that seems to be misbehaving?

    Alan

  • I got my example code to work exactly the way I wanted it to.  I had modified one of the examples that uses a timer and a semaphore to print "Hello World" to a log buffer.  It appears the issue was with the semaphore.  When I changed the implementation to wait on an event and not a semaphore it magically started working.

    So the code that didn't work was like this

    Void myTaskFxn(Void)
    {
        transportMsg aMsg;
        /*
         * Do this forever
         */
        while (TRUE) {
            /*
             * Pend on "mySemaphore" until the timer ISR says
             * its time to do something.
             */
            Semaphore_pend(mySem, BIOS_WAIT_FOREVER);
            aMsg.cmdID=0x1234;
            aMsg.pktLength=14;
            aMsg.ptrData= (Uint16 *)test_str;
            aMsg.replyHandle = 0x0000;
            Mailbox_post(ptr_msgTask->_Mailbox,&aMsg, 12);
        }
    }

    The mailbox post was received, but the message could not be read. MySem was created in the cfg file. Now when I changed the implementation to this

    Void myTaskFxn(Void)
    {
        Uint16 events;
        transportMsg aMsg;
        /*
         * Do this forever
         */
        while (TRUE) {
            /*
             * Pend on "tickEvent" until the timer ISR says
             * its time to do something.
             */
            events = Event_pend(tickEvent,
                            Event_Id_NONE,        // andMask = 0
                            Event_Id_00,        // or mask
                            BIOS_WAIT_FOREVER);
            if (events & Event_Id_00)
            {
                aMsg.cmdID=0x1234;
                aMsg.pktLength=14;
                aMsg.ptrData= (Uint16 *)test_str;
                aMsg.replyHandle = 0x0000;
                Mailbox_post(ptr_msgTask->_Mailbox,&aMsg, 12);
            }
        }
    }

    Everything worked.  tickEvent was created in the main code, not the cfg file.  Overall, I would rather create my objects myself and not rely on the cfg file.

  • What thread was posting the Semaphore in the code that did not work? If it was a task thread, and the Semaphore was posted BEFORE the Mailbox, then the task pending on the Semaphore would have unblocked and run BEFORE the Mailbox would have been posted.

    Alan