I have the following code which reads characters from a queue and puts them on the LCD:
lcdInit(); /*initialize LCD*/
for (; ;)
if ((qLCD != 0) && (xQueueReceive(qLCD, &ch, portMAX_DELAY) == pdPASS))
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)) ;
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).
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)
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.
Anyway, the hangup won’t occur if either receive or send is commented up.
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.
xQueueHandle qLCD = 0;
helped me a lot.
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.