Sending a structure that has an character array using xQueueSend()

Hello. I have a simple problem I want to ask I am sending a struct through freertos queue ~~~ //Structure to pass to a queue typedef struct { char mess[2000]; int id; }queuemessagepassingstruct ~~~ When I have copied the contents into struct members and send it the board gets hanged. But, If i sue a pointer like this ~~~ //Structure to pass to a queue typedef struct { char mess*; int id; }queuemessagepassingstruct ~~~ It works FINE. What is the reason behind this and how should I fix this.

Sending a structure that has an character array using xQueueSend()

Queues copy data into the queue buffer. If the message you are inserting into the queue, is bigger than the queue, it won’t work. Your pointer to mess is only 4 byes. Your first queuemessagepassingstruct is over 2004 bytes not including the overhead used by FreeRTOS. Your second queuemessagepassingstruct is only 8 bytes. Post the code you used to create the Queue.

Sending a structure that has an character array using xQueueSend()

~~~ //Structure to pass to a queue typedef struct { char mess[2000]; int id; }queuemessagepassingstruct // Creating an instance of a struct queuemessagepassingstruct mess; //Creating a queue handle QueueHandlet xQueue1; //Some function in which queue is created void somefunctiontocreate_queue() { xQueue1 = xQueueCreate(1,sizeof(mess)); } ~~~

Sending a structure that has an character array using xQueueSend()

Do you check that the value of xQueue1 is not 0 after the create. If your heap doesn’t have enough spare room to make that big of a structure, it will return 0, and if you don’t detect and report that, when you use that 0 as a queue handle problems will occur.

Sending a structure that has an character array using xQueueSend()

It return pdPASS

Sending a structure that has an character array using xQueueSend()

xQueueCreate does NOT return a status flag, but a queue handle, so xQueue1 could NOT be pdPASS (which is the value 1). If by ‘pdPASS’, you mean it was not 0, then that is good.

Sending a structure that has an character array using xQueueSend()

Sorry, It return PDPASS when I send the data using xQueueSend()

Sending a structure that has an character array using xQueueSend()

That doesn’t answer the question then. When creating the queue, did you check that the queue handle was not 0 aftger the create? (your shown code doesn’t have a test) A second issue also could be do the sending and receiving task have enough stack space. If the structure is stored on their stack, it will require 2004 bytes of statck space, and if that is not available you could be overruning it and corrupting something else in memory.