groger57 wrote on Tuesday, June 20, 2017:
Hello,
So I now have various tasks using a queue to send data, and a receive queue to send to the UART. It seems to work OK, but wants to hang up somewhere. It’s a touch screen app - for example, the clock stops updating, and if I touch a “hot spot” on the screen that generates a message, all of a sudden the receive queue starts to respond and spew out all the messages that are apparently backed up. I have a queue size of 35. This is the receive function.
void QueueRxFunction( void *pvParameters )
{
BaseType_t xStatus;
QueueHandle_t xQueue;
xQueue = (QueueHandle_t) pvParameters;
for(;;)
{
//value of 1500 seems to work
xStatus = xQueueReceive( xQueue, &uartMssg, 1500 );
if( xStatus == pdPASS )
{
UBaseType_t spaces = uxQueueSpacesAvailable( xQueue );
if( spaces == 1 ) assert(QUEUE_LOW_SPACE);
uint8_t chkErr = SCRNCOM_GetResponse( uartMssg.message );
if( chkErr != RCVD_PROMPT ) assert(UART_ERR1);
}
else
{
printf("Couldn't queue message: %s\n", uartMssg.message);
assert(UART_ERR2);
}
}
}
The function SCRNCOM_GetResponse is basically a UART send and then poll for response:
SCRNCOM_GetResponse( char *s)
{
while(*s)
{
//while transmit buffer is not empty…
while( USART_GetFlagStatus(USART2, USART_FLAG_TXE ) == RESET);
USART_SendData(USART2, *s++);
}
while(1) // poll response
{
//wait for data: USART_FLAG_RXNE will be reset
while( USART_GetFlagStatus( USART2, USART_FLAG_RXNE) == RESET );
rxCode = USART_ReceiveData( USART2 );
if( rxCode == RCVD_PROMPT )
{
//one more for 0xD (end of message)
while( USART_GetFlagStatus( USART2, USART_FLAG_RXNE) == RESET );
rxCode = USART_ReceiveData( USART2 );
break;
}
}
return rxCode;
}
If I reduce the value of xQueueReceive’s wait to about 1200 or lower, I start to get the messaging printing and the assert handler going.
With a UART baud of 115,200 it is hard to imagine the UART backing up and the receive queue having to wait 1-1/2 seconds. There’s just not that many messages and formatting strings being sent out.
Every place I send to the queue, looks like this:
xQueueSend(mssgQueue, (void*)&xMssg, portMAX_DELAY);
Should I be using a similar number of ticks to wait there too?
I also have the configCHECK_FOR_STACK_OVERFLOW defined, and the task to catch the error. It never lands there.
Thanks!