ajlennon wrote on Sunday, July 14, 2013:
Hi,
I am seeing a problem when I try to queue a message onto a FreeRTOS queue, which I suspect this is because I am going about it the wrong way.
I am using FreeRTOS 7.4.2 and the MSVC-MinGW port which I am using within Visual Studio 2010
(This is because for this project I want to simulate numbers of nodes running, each of which will be a separate instance of a FreeRTOS based application. Once I have written and validated my code I will then be porting to the real hardware)
Currently I am bringing up a single instance of FreeRTOS with a very basic comms. handler thread which dequeues a message and deals with it:
static void prvCommsTask( void *pvParameters )
{
serialPacket_t packet;
while(1)
{
if(xQueueReceive(_rxQueue, &packet, portMAX_DELAY))
{
// Loopback
if(_cb)
_cb(_sender, packet.pData, packet.length);
free(packet.pData);
}
}
}
[code]
I am queueing that message from a thread which is called from outside of the FreeRTOS sandbox though.
(the critical section is something I added to try to deal with the problem, but it doesn't help)
[code]
..
taskENTER_CRITICAL();
ret = xQueueSend(_rxQueue, (const void *)&packet, 500);
taskEXIT_CRITICAL();
}
[/code]
When I run up my test, sending a packet of data into FreeRTOS I get an exception in list.c, uListRemove() on the following line
[code]
/* The list item knows which list it is in. Obtain the list from the list
item. */
pxList = ( xList * ) pxItemToRemove->pvContainer;
/* Make sure the index is left pointing to a valid item. */
[b] if( pxList->pxIndex == pxItemToRemove )[/b]
[/code]
This is because pvContainer is NULL, which would seem to indicate the list item is somehow unhooked from its list. It makes me think there is perhaps a race.
In the real device the bytes would come in on a UART, trigger the interrupt handler, and I presume all would be well.
Any feedback on the above would be much appreciated, or any thoughts on a better implementation to get bytes into FreeRTOS from a hosted environment.
Many thanks,
Alex Lennon
Dynamic Devices