Hi everyone,
I’m currently working on a project using FreeRTOS, and I’ve run into an issue that I can’t seem to figure out. I’m hoping someone here might be able to help me out.
I’m trying to send data to a queue using xQueueSend
, but I keep getting a “Queue Send Error”. Here’s a bit more detail about what I’m doing:
- I’ve created a queue with a length of 5 and a size of sizeof(int).
- I have a task that generates data and tries to send it to the queue.
- I’m using
xQueueSend
with a block time ofpdMS_TO_TICKS(100)
.
However, it seems like the queue is always full, and xQueueSend
fails. Here’s the relevant code snippet:
QueueHandle_t myQueue;
int data = 42;
void vProducerTask(void *pvParameters)
{
myQueue = xQueueCreate(5, sizeof(int));
if (myQueue == NULL)
{
// Error handling
}
for (;;)
{
if (xQueueSend(myQueue, &data, pdMS_TO_TICKS(100)) != pdPASS)
{
// Queue send error handling
printf("xQueueSend failed to send message to myQueue.\n");
}
vTaskDelay(pdMS_TO_TICKS(200)); // Delay to simulate work
}
}
When I was searching about this I came across to these resources Message Queue Errors - FreeRTOS GCP Interview Questions, and as per them I tried the following.
- I tried by Increasing the queue length.
- I tried by Increasing the block time in
xQueueSend
. - I have cross checked if the task sending data is running too fast compared to the task consuming data.
But none of these seem to work. The consumer task is reading from the queue, but it seems like it’s not able to keep up, even though I’ve tried to slow down the producer task.
Has anyone faced a similar issue or have any suggestions on what I might be doing wrong? Any tips on how to debug this would be greatly appreciated!
Thanks in advance!