This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

mailbox

Hello,
I would like to use a mailbox and i've studied the RTX manual. But i still have a problem.. I want to use the message of the mailbox in a switch, but i cannot understand what i should pass to the switch.

Here is the part of the code:

void* msg;

        while(1) {


        os_mbx_wait(MsgBox,&msg,0xffff);

                switch (*msg){
                        case button_right :
                                counter +=2;
                                break;
                        case button_up:
                                counter ++;
                                break;
                        case button_down:
                                counter --;
                                break;
                        case button_left:
                                counter -=2;
                                break;
                        case button_select:
                                break;

And the error i receive is:

tisifone_task_2b.c(73): error:  #31: expression must have integral type
tisifone_task_2b.c:             switch (*msg){


The message came from another task which send a pointer to an int.

How can i work with a message coming from a mailbox?? Many thanks.

Parents
  • > In your case I'd add a cast (void *) in the call to the function that expects void.

    That should have read (void **), since the routine writes a pointer to the location of the actual mailbox item. There's a message (e.g. an int), the address of that msg, (e.g. int *p=&msg) and a pointer to that pointer, which the mailbox routine uses.

Reply
  • > In your case I'd add a cast (void *) in the call to the function that expects void.

    That should have read (void **), since the routine writes a pointer to the location of the actual mailbox item. There's a message (e.g. an int), the address of that msg, (e.g. int *p=&msg) and a pointer to that pointer, which the mailbox routine uses.

Children