This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294KCPDT: ti-rtos queue not receive more then one message

Part Number: TM4C1294KCPDT
Other Parts Discussed in Thread: SYSBIOS

i am using tm4c1294 with ti rtos in that we have used 5 to 6 task and for intertask communication we have used queue
but it is not properly receive data from queue. from document it is given that queue is FIFo base but i get only last message
how to get all the message from queue

i was try to send at one time 1, 2,3 and then 3,4,5 form taskA to taskB but i only receive 3,4,5 continously. how we will get 1,2,3 data.?

typedef struct
{
Queue_Elem elem;
unsigned char channel;
EN_OUTPUT_TYPE enOutputType;
EN_OUTPUT_CMD enOutputCmd;
// EN_AUDIO_TYPE enAudioType;
}ST_OUTPUT;

#define OUTPUT_CTRL(A, B, C, D, E) { \
A.enOutputType = C; \
A.enOutputCmd = D; \
A.channel = E; \
Queue_enqueue(B, &(A.elem)); \
}

ST_OUTPUT st_aloutput_Appl;

Queue_Handle xAPPLICATION_Queue;
Queue_Handle xOUTPUT_Queue ;
///////////////////////////////////////////////////////////
queue created using this

xAPPLICATION_Queue = Queue_create(NULL, NULL);
xOUTPUT_Queue = Queue_create(NULL, NULL);
///////////////////////////////////////////////////////////

taskA()
{
while(1)
{
//some code


OUTPUT_CTRL(st_aloutput_Appl, xAPPLICATION_Queue, 1,2,3);
OUTPUT_CTRL(st_aloutput_Appl, xAPPLICATION_Queue, 4,5,6);

System_printf("send\n");
System_flush();

}
Task_sleep(1000);
}

ST_OUTPUT *st_output_pt;
taskB()
{
while(1)
{
if(! Queue_empty(xOUTPUT_Queue))
{

// st_output_pt = Queue_get(xOutput_Queue);
st_output_pt = Queue_dequeue(xOutput_Queue);

System_printf("o/p task recv %u %u %u \n",st_output_pt->enOutputType,st_output_pt->enOutputCmd,st_output_pt->channel);
System_flush();

}
Task_sleep(100);
}

at console we get data like following . why 4,5,6 receive continously and 1,2,3 is not receive

send
o/p task
o/p task recv 4 5 6
o/p task
o/p task recv 4 5 6
o/p task
o/p task recv 4 5 6
o/p task
o/p task recv 4 5 6
o/p task
o/p task recv 4 5 6
o/p task
o/p task recv 4 5 6
o/p task
o/p task recv 4 5 6
o/p task
o/p task recv 4 5 6
o/p task
o/p task recv 4 5 6
send

///////////////////////////////////////////////////////////////////////////////
if i comment the following line from sender task i.e taskA then we will properly receive data and queue gets empty as well which is not in above case , so what is the problem for more then one message ?
OUTPUT_CTRL(st_aloutput_Appl, xAPPLICATION_Queue, 4,5,6);

console we get

o/p task
o/p task recv 1 2 3
o/p task
o/p task
o/p task
o/p task
o/p task
o/p task
o/p task
o/p task
o/p task
send


//////////////////////////////////////////////////////////////////////////

  • Hi Saurabh,

    Queue_enqueue() and Queue_dequeue() are not atomic.  If you're using these functions to manipulate the Queue from multiple tasks, you probably need to add Hwi_disable()/Hwi_restore() around these calls.  Here is an example from the Queue documentation:

         #include <ti/sysbios/hal/Hwi.h>

         key = Hwi_disable();


         if ((Queue_Handle)(elem = Queue_dequeue(q)) != q) {
             ` process elem `
         }

         Hwi_restore(key);

    Please let me know if that does not fix the problem.

    Best regards,

    Janet