<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: LWMSGQueue clarification needed in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/LWMSGQueue-clarification-needed/m-p/1577204#M18779</link>
    <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/369"&gt;@danielchen&lt;/a&gt;&amp;nbsp;thanks for helping!&lt;/P&gt;&lt;P&gt;So if I understand correctly, if my structure is:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;typedef struct my_struct
{
    uint16_t a;
    uint16_t b;
    uint8_t c;
} my_struct_t&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That would be 40 bits only, therefore I would have to make my structure as:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;typedef struct my_struct
{
    uint16_t a;
    uint16_t b;
    uint8_t c;
    uint8_t reserved[3];
} my_struct_t&lt;/LI-CODE&gt;&lt;P&gt;To make it 64 bits and be able to use it, is this correct?&lt;/P&gt;&lt;P&gt;Then, should the array declaration and queue initialization be:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#define NUM_MESSAGES  3
#define MSG_SIZE      2 /* 2 because the struct is 64bits long, correct? */

uint32_t server_queue [sizeof(LWMSGQ_STRUCT)/sizeof(uint32_t) + NUM_MESSAGES * MSG_SIZE];

_lwmsgq_init((void *)server_queue, NUM_MESSAGES, MSG_SIZE);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or, written in terms of the structure:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#define NUM_MESSAGES  3
#define MSG_SIZE      sizeof(my_struct)/sizeof(_mqx_max_type)

uint32_t server_queue [sizeof(LWMSGQ_STRUCT)/sizeof(uint32_t) + NUM_MESSAGES * MSG_SIZE];

_lwmsgq_init((void *)server_queue, NUM_MESSAGES, MSG_SIZE);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this correct?&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jan 2023 15:15:07 GMT</pubDate>
    <dc:creator>mmalagon</dc:creator>
    <dc:date>2023-01-04T15:15:07Z</dc:date>
    <item>
      <title>LWMSGQueue clarification needed</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/LWMSGQueue-clarification-needed/m-p/1576723#M18777</link>
      <description>&lt;P&gt;I have a confusion about the usage of lightweight message queues that should be very easy to resolve by someone with experience on MQX. I can see on the example code included in MQX that the array is declared as:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#define NUM_MESSAGES  3
#define MSG_SIZE      1

uint32_t server_queue[sizeof(LWMSGQ_STRUCT)/sizeof(uint32_t) + NUM_MESSAGES * MSG_SIZE];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And that is is being initialized as:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;_lwmsgq_init((void *)server_queue, NUM_MESSAGES, MSG_SIZE);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, my question is simple, how should I declare my queue array and initialize the queue if I have the following structure:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;typedef struct my_struct
{
    uint32_t a;
    uint8_t b;
    char *c[32]
    uint32_t *d;
} my_struct_t;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ask because the example uses &lt;STRONG&gt;uint32_t&lt;/STRONG&gt; which is not that helpful. The fact it uses uint32_t causes confusion about what to change to adapt the example to what I need. For instance, should I declare my array as:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;my_struct_t server_queue[sizeof(LWMSGQ_STRUCT)/sizeof(my_struct_t) + NUM_MESSAGES * MSG_SIZE];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And what about the initialization? There seems like there is nothing to change about it because it doesn't include the data type. Is it really the exact same initialization regardless of the data type used for the queue? That doesn't sound right.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 21:51:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/LWMSGQueue-clarification-needed/m-p/1576723#M18777</guid>
      <dc:creator>mmalagon</dc:creator>
      <dc:date>2023-01-03T21:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: LWMSGQueue clarification needed</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/LWMSGQueue-clarification-needed/m-p/1577104#M18778</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please check the _lwmsgq_init ,&amp;nbsp; &amp;nbsp;Lightweight message queues are a simpler, low-overhead implementation of standard MQX RTOS messages. Tasks send messages to lightweight message queues and receive message from lightweight message queues.&amp;nbsp; A message in the message pool has a fixed size, a multiple of 32 bits.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="danielchen_0-1672834039000.png" style="width: 604px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/206061iFBFBFD0848579DC5/image-dimensions/604x284?v=v2" width="604" height="284" role="button" title="danielchen_0-1672834039000.png" alt="danielchen_0-1672834039000.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 12:12:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/LWMSGQueue-clarification-needed/m-p/1577104#M18778</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2023-01-04T12:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: LWMSGQueue clarification needed</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/LWMSGQueue-clarification-needed/m-p/1577204#M18779</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/369"&gt;@danielchen&lt;/a&gt;&amp;nbsp;thanks for helping!&lt;/P&gt;&lt;P&gt;So if I understand correctly, if my structure is:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;typedef struct my_struct
{
    uint16_t a;
    uint16_t b;
    uint8_t c;
} my_struct_t&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That would be 40 bits only, therefore I would have to make my structure as:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;typedef struct my_struct
{
    uint16_t a;
    uint16_t b;
    uint8_t c;
    uint8_t reserved[3];
} my_struct_t&lt;/LI-CODE&gt;&lt;P&gt;To make it 64 bits and be able to use it, is this correct?&lt;/P&gt;&lt;P&gt;Then, should the array declaration and queue initialization be:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#define NUM_MESSAGES  3
#define MSG_SIZE      2 /* 2 because the struct is 64bits long, correct? */

uint32_t server_queue [sizeof(LWMSGQ_STRUCT)/sizeof(uint32_t) + NUM_MESSAGES * MSG_SIZE];

_lwmsgq_init((void *)server_queue, NUM_MESSAGES, MSG_SIZE);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or, written in terms of the structure:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#define NUM_MESSAGES  3
#define MSG_SIZE      sizeof(my_struct)/sizeof(_mqx_max_type)

uint32_t server_queue [sizeof(LWMSGQ_STRUCT)/sizeof(uint32_t) + NUM_MESSAGES * MSG_SIZE];

_lwmsgq_init((void *)server_queue, NUM_MESSAGES, MSG_SIZE);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this correct?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 15:15:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/LWMSGQueue-clarification-needed/m-p/1577204#M18779</guid>
      <dc:creator>mmalagon</dc:creator>
      <dc:date>2023-01-04T15:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: LWMSGQueue clarification needed</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/LWMSGQueue-clarification-needed/m-p/1578286#M18780</link>
      <description>&lt;LI-CODE lang="c"&gt;#define NUM_MESSAGES  3
#define MSG_SIZE      sizeof(my_struct)/sizeof(_mqx_max_type)

uint32_t server_queue [sizeof(LWMSGQ_STRUCT) + NUM_MESSAGES * MSG_SIZE];

_lwmsgq_init((void *)server_queue, NUM_MESSAGES, MSG_SIZE);&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 06 Jan 2023 03:05:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/LWMSGQueue-clarification-needed/m-p/1578286#M18780</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2023-01-06T03:05:31Z</dc:date>
    </item>
  </channel>
</rss>

