xQueueSend

ryuhhh
Posts: 7
Joined: Sun Dec 18, 2016 6:31 am

xQueueSend

Postby ryuhhh » Thu Dec 22, 2016 10:10 am

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?

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: xQueueSend

Postby ESP_Sprite » Thu Dec 22, 2016 12:37 pm

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))

Who is online

Users browsing this forum: No registered users and 66 guests