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

**URL:** <https://forums.freertos.org/t/sending-a-structure-that-has-an-character-array-using-xqueuesend/7418>\
**Category:** Kernel\
**Created:** [September 14, 2018, 7:16am UTC](https://forums.freertos.org/t/sending-a-structure-that-has-an-character-array-using-xqueuesend/7418 "2018-09-14T07:16:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 14, 2018, 7:16am UTC](https://forums.freertos.org/t/sending-a-structure-that-has-an-character-array-using-xqueuesend/7418/1 "2018-09-14T07:16:21Z")

</div>

**[saadsaeed](https://sourceforge.net/u/saadsaeed/)** wrote on [Friday, September 14, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/d229b410/#368d):

Hello.  
I have a simple problem I want to ask  
I am sending a struct through freertos queue

```auto
//Structure to pass to a queue
typedef struct
{
	char mess[2000];
	int id;
}queue_message_passing_struct

```

When I have copied the contents into struct members and send it the board gets hanged. But, If i sue a pointer like this

```auto
//Structure to pass to a queue
typedef struct
{
	char mess*;
	int id;
}queue_message_passing_struct

```

It works FINE. What is the reason behind this and how should I fix this.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 14, 2018, 1:18pm UTC](https://forums.freertos.org/t/sending-a-structure-that-has-an-character-array-using-xqueuesend/7418/2 "2018-09-14T13:18:52Z")

</div>

**[jeronimo479](https://sourceforge.net/u/jeronimo479/)** wrote on [Friday, September 14, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/d229b410/#8e84):

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 queue\_message\_passing\_struct is over 2004 bytes not including the overhead used by FreeRTOS. Your second queue\_message\_passing\_struct is only 8 bytes.

Post the code you used to create the Queue.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 15, 2018, 6:18am UTC](https://forums.freertos.org/t/sending-a-structure-that-has-an-character-array-using-xqueuesend/7418/3 "2018-09-15T06:18:36Z")

</div>

**[saadsaeed](https://sourceforge.net/u/saadsaeed/)** wrote on [Saturday, September 15, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/d229b410/#5478):

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

```

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 15, 2018, 1:04pm UTC](https://forums.freertos.org/t/sending-a-structure-that-has-an-character-array-using-xqueuesend/7418/4 "2018-09-15T13:04:54Z")

</div>

**[richarddamon](https://sourceforge.net/u/richarddamon/)** wrote on [Saturday, September 15, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/d229b410/#1fc6):

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.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 15, 2018, 2:22pm UTC](https://forums.freertos.org/t/sending-a-structure-that-has-an-character-array-using-xqueuesend/7418/5 "2018-09-15T14:22:18Z")

</div>

**[saadsaeed](https://sourceforge.net/u/saadsaeed/)** wrote on [Saturday, September 15, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/d229b410/#ea7b):

It return pdPASS

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 15, 2018, 2:37pm UTC](https://forums.freertos.org/t/sending-a-structure-that-has-an-character-array-using-xqueuesend/7418/6 "2018-09-15T14:37:58Z")

</div>

**[richarddamon](https://sourceforge.net/u/richarddamon/)** wrote on [Saturday, September 15, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/d229b410/#1495):

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.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 16, 2018, 7:49am UTC](https://forums.freertos.org/t/sending-a-structure-that-has-an-character-array-using-xqueuesend/7418/7 "2018-09-16T07:49:30Z")

</div>

**[saadsaeed](https://sourceforge.net/u/saadsaeed/)** wrote on [Sunday, September 16, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/d229b410/#1dcc):

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

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 16, 2018, 10:30am UTC](https://forums.freertos.org/t/sending-a-structure-that-has-an-character-array-using-xqueuesend/7418/8 "2018-09-16T10:30:14Z")

</div>

**[richarddamon](https://sourceforge.net/u/richarddamon/)** wrote on [Sunday, September 16, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/d229b410/#1ac9):

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.
