Page 1 of 1

passing pointer to structure via message box

Posted: Sat Apr 26, 2014 6:38 pm
by Tabulous
is this the correct way to pass a pointer to a structure via Message Box ?

Code: Select all

typedef struct
{
    char body[64];
    char number[14];
}Msg_TypeDef;

void some_func (void)
{
Msg_TypeDef msg;


        strcpy(msg.body, "MSG_RECV");

        chsnprintf(msg.number,
                   sizeof(msg.number),
                   "%d", QueueIndex );

        chMBPost(&mbox, (msg_t)&msg, TIME_INFINITE);
}

Re: passing pointer to structure via message box

Posted: Sat Apr 26, 2014 8:04 pm
by Giovanni
Yes, it is correct, you just cast the pointer to a msg_t.

Giovanni