gstenos wrote on Wednesday, August 17, 2016:
I am having issues using the xQueueReceive function, I can not get the function to work properly and it also causes my whole system to halt. The version of FreeRTOS that I am using with my hardware is v7.3
I stepped through the debugger and identified the line of code that the system “halts” at, however, xQueueGenericReceive iterates through multiples times before the issue occurs.
The issue has occured on the 3rd and 4th iteration of when the function vListInsert. The code hangs up on line 165 in list.c which is given below:
for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext )
The entire for loop is:
for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext )
{
/* There is nothing to do here, we are just iterating to the
wanted insertion position. */
}
This is how I go about setting up my queue, how I send and how I receive.
typedef struct
{
char ucMessageID;
char ucData[ 20 ];
} AMessage;
xQueueHandle xQueue;
Setup_Function()
{
xQueue = xQueueCreate( 10, sizeof( AMessage *) );
}
Task_A()
{
AMessage *pxMessage;
memset(pxMessage->ucData, 0x00, sizeof(pxMessage->ucData));
for(;;)
{
pxMessage->ucMessageID = 0xDD;
pxMessage->ucData[0] = 'T';
pxMessage->ucData[1] = 'E';
pxMessage->ucData[2] = 'S';
pxMessage->ucData[3] = 'T';
pxMessage->ucData[4] = 'S';
xQueueSend( xQueue, ( void * ) pxMessage, ( portTickType ) 0 );
//rest of task code
}
}//end Task_A
Task_B()
{
AMessage *pxRxedMessage;
for(;;)
{
if( xQueueReceive( xQueue, pxRxedMessage, ( portTickType ) 10 ) )
{
// pcRxedMessage now points to the struct AMessage variable posted
// by vATask.
printf("Received: %c%c%c%c%c\n", pxRxedMessage->ucData[0], pxRxedMessage->ucData[1], pxRxedMessage->ucData[2], pxRxedMessage->ucData[3], pxRxedMessage->ucData[4]);
}
}
}//end Task_B
I have verified that I am able to send something into the queue with the following print statement;
printf(“Number of messages in queue: %lu\n”, uxQueueMessagesWaiting(xQueue));
Then when I was trying to receive in another task to make sure all the data was correct, I started to have the issue that I outlined above. Nothing else on the system will execute once the line of code with xQueueReceive hits.
I’ve tried passing in just a struct AMessage as opposed to a pointer of struct AMessage, however the same issue occured where I verifed that messages were being sent to the queue but when xQueueReceive was commented out, the same issues occur.