Page 1 of 1

xQueueSend

Posted: Thu Dec 22, 2016 10:10 am
by ryuhhh
Hi, I have a problem to use xQueueSend function.

Here is my code.

Code: Select all

xQueueHandle hQueue1 = 0;
void Sender_Task(void *p)
{
    int i=0;
    while(1) 
    {
      printf("Send %i to receiver task\n", i);

      if (! xQueueSend(hQueue1, &i, 1000))
      {
        printf("Failed to send to queue\n");
      }
      i++;
      vTaskDelay(100);
  }
}

void Receiver_Task(void *p)
{
    int rx_int = 0;
    while(1) {
      if (xQueueReceive(hQueue1, &rx_int, 1000))
      {
        printf("Received %i\n", rx_int);
      }
      else
      {
        printf("Failed to receive data from queue\n");
      }
    }
}



void app_main()
{
    nvs_flash_init();
    hQueue = xQueueCreate(QUEUE_SIZE, sizeof(int));

    xTaskCreate(&Sender_Task, "sender_task", 2048, NULL, 5, NULL);
    xTaskCreate(&Receiver_Task, "receiver_task", 2048, NULL, 5, NULL);
}

and from uart, I received a message, "freertos/queue.c:721 [xQueueGenericSend] - assert failed"
And just after it, Guru Mediation error follows.

Is there anything mistake in my code?

Re: xQueueSend

Posted: Thu Dec 22, 2016 12:37 pm
by ESP_Sprite
That location asserts if the queue is NULL. Are you sure you copy-pasted all your code? Especially these contradict eachother:
hQueue = xQueueCreate(QUEUE_SIZE, sizeof(int));
if (! xQueueSend(hQueue1, &i, 1000))