FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2009 Threads] Queue blockPosted by Grigore-Mihai Dobra on May 2, 2009 I have the following code which reads characters from a queue and puts them on the LCD:
portTASK_FUNCTION_PROTO(vLCDTask, pxParameters) { portCHAR ch; lcdInit(); /*initialize LCD*/ for (; ;) { if ((qLCD != 0) && (xQueueReceive(qLCD, &ch, portMAX_DELAY) == pdPASS)) { lcdDispCh(ch); } } }
and the following code to feed up a queue(from another task):
unsigned portSHORT lcdPutS(unsigned portCHAR* str) { while ((str) && (*str) && (qLCD != 0) && (xQueueSend(qLCD, str++, portMAX_DELAY) == pdTRUE)) ; return 1; }
But my system seems to be blocked somewhere. I expect it to print on the LCD as I feed the queue with data.
Aren't the tasks supposed to YIELD if queue empty on receive or queue full on send? This way, whichever event comes first, will allow the other task to do its job(send on queue empty or receive on queue full).
RE: Queue blockPosted by Richard on May 2, 2009 Could it be tat qLCD is NULL? Do you know that lcdDispCh() works correctly? Are you sure str points to printable characters?
Separate to your question, portTASK_FUNCTION_PROTO can be used to define the function prototype, rather than the actual function. In nearly all cases you don't need to use these macros at all and you can just use void vLCDTask( void *pxParameters)
Regards.
RE: Queue blockPosted by Grigore-Mihai Dobra on May 2, 2009 qLCD being null won't hang the whole system. lcdDispCh() working or not won't hang the whole system. str points to "Hello there!" and nothing more, that won't hang the whole system either.
Finally, the watchdog eats me up because I seem to hang up here:
for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*in vListInsert*/
pxIterator seems to be 0x00 and pxIterator->pxNext seems to be 0x00 too.
If my expectations from the two initial functions is right, then I might found another bug in my shitty compiler. So please confirm the expected behaviour should be the one described in the first post.
Thanks.
RE: Queue blockPosted by Grigore-Mihai Dobra on May 2, 2009 Anyway, the hangup won't occur if either receive or send is commented up.
RE: Queue blockPosted by Grigore-Mihai Dobra on May 2, 2009 Ok... The faulty system seems to be me... :)) The task which is sending gets run before the task which creates the queue gets run. qLCD is thus not initialized, nor it was initialized to 0. So, the task that's sending will send to a bogus queue, eventually thrashing out some variables. This results in the described hang. So:
xQueueHandle qLCD = 0;
helped me a lot.
RE: Queue blockPosted by Samuel Tardieu on May 2, 2009 Why are you creating the queue in a task, rather than before starting the scheduler? You would not need to test that the queue is not null anymore, and won't run into those problems.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|