Hi,
I am trying to use a queue as FIFO between two task.
I am having a weird problem. If i have only one element into the Queue, the dequeue is fine and the "Queue_empty" function returns 1. But when I try to put more than one element, the dequeue is doing well until the queue is empty, the "queue_empty" function return 0 (even if there isn't any element in the queue)and it keeps looping return element from the empty queue.
The Enqueue is done in a running task and the dequeue is done into a network launched (when IP is obtained) task.
SPI_frame *fToSend; if(!Queue_empty(SPI_frame_Queue) && EMAC_isLinkUp(0)) { fToSend = Queue_get(SPI_frame_Queue); queueCounter--; System_printf("Empty : %d\n",Queue_empty(SPI_frame_Queue)); } /*********************************************************************/ if(queueCounter < QUEUE_MAX_NUMBER_OF_FRAMES) { Queue_put(SPI_frame_Queue,&(f.elem)); queueCounter++; } System_printf("Add to queue : %d\n",queueCounter);
I can't manage to find the problem. Also is there any other solution than putting a variable counter, to track the number of element in the queue ?
thank you for your help,
Best regards,