passing pointer to structure via message box

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

passing pointer to structure via message box

Post 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);
}
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: passing pointer to structure via message box

Post by Giovanni »

Yes, it is correct, you just cast the pointer to a msg_t.

Giovanni
Post Reply