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.

question on "MessageQ allocation and Heaps"

Hi, everyone. I have posted one similar question before, However there is still something unclear in the relationship between the message and the allocated heap.

Let me take an example for it. If I want to send a message defined as below:

    typedef struct {
    MessageQ_MsgHeader reserved;
    float my_data[9];
    } App_Msg;

How should I set the size and number of the heap which will be allocated to the message then?

That is to say. When I use the API:

     HeapBufMP_Params_init(&heapParams);

How should I set the two parameters:

    heapParams.blockSize 

    heapParams.numBlocks 


Is there anyone having an idea? Please share with me. Thank you very much!

  • Hi,

    Let me take an example for it. If I want to send a message defined as below:

        typedef struct {
        MessageQ_MsgHeader reserved;
        float my_data[9];
        } App_Msg;

    This size is calculated by the below line of code for module.

        Module.msgSize = sizeof(App_Msg);

    .....

            /* allocate message */
            msg = (App_Msg *)MessageQ_alloc(Module.heapId, Module.msgSize);

    HeapBufMP_Params_init(&heapParams);


    This size is calculated by the below line of code for message.

        heapParams.blockSize = 64;
        heapParams.numBlocks = 10;

    I hope this helps.

  • Thank you for your answer, and it do help. But, I still cannot understand the relationship between the size of the message and the heap that is allocated to the message. 

    I still use my example, where I want to send an array with 9 float numbers in the message.

    As your answer, I should use 10 blocks of heaps, and each block's size is 64. So I really want to know how did you calculate them out. From the message I want to send, how can I carry out the heap I need to use? 

    Can you tell me please. Thank you

    Titusrathinaraj Stalin said:

    Hi,

    Let me take an example for it. If I want to send a message defined as below:

        typedef struct {
        MessageQ_MsgHeader reserved;
        float my_data[9];
        } App_Msg;

    This size is calculated by the below line of code for module.

        Module.msgSize = sizeof(App_Msg);

    .....

            /* allocate message */
            msg = (App_Msg *)MessageQ_alloc(Module.heapId, Module.msgSize);

    HeapBufMP_Params_init(&heapParams);


    This size is calculated by the below line of code for message.

        heapParams.blockSize = 64;
        heapParams.numBlocks = 10;

    I hope this helps.

    [/quote]

  • Hi Chengyang,

    Could you please tell me that what problem are you facing?

    I would like to suggest that refer the below ti e2e thread which is explaining about the heap & messageQ operations and its configurations.

    http://e2e.ti.com/support/embedded/tirtos/f/355/t/145079.aspx?pi68665=1