Hello Gerado
Thank you for your reply.
I have spent a few days trying different methods of implementing a time out without success.
I have a test string that I send out and a known length returned from and on board device that has the UART interface. I can receive exactly the correct number of char’s of the returned string, any fewer than that and the driver hangs.
I have tried using a callback with a timer that sets a flag, the driver checks the flag when it has run out of characters. That causes the return buffer to be null for some reason. I then tried using a binary semaphore and breaking out of the loop when the call back signals the timeout has lapsed. That also causes a failure to receive a valid buffer. In fact even asking for the exact known number of characters with this code added even when not called, causes the buffer to be returned empty. This I do not understand.
I have tried a multitude of ways with the interrupt driven and now polled and can not get this to work.
I have attached the code and would appreciate any advice you can give.
The main module, is r12.c and starts a task called Bt_Mon_Tsk, that task sends a command through the OutputFcns.c module, u32Fn_BtCmd, this is the code that sends out the string, and receives the reply. The callback r12.c/…uartCharTimeOutCallback gives the semaphore.
Bt_Mon_task, calls OutputFcns.c/…u32Fn_BtCmd(geBT_TEST_STR)
Which calls the write and read driver for the uart. The write driver works ok, it is the read that is a problem.
u32Fn_BtReadStr
starts the timer then calls
UART_ReadBlocking(UART0,
gca_rxBuffer,
14);
This last driver is in the module fsl_uart.c
status_t UART_ReadBlocking(UART_Type *base, uint8_t *data, size_t length)
{
assert(data);
uint32_t statusFlag;
while (length--)
{
while (!base->RCFIFO)
{
statusFlag = UART_GetStatusFlags(base);
if (statusFlag & kUART_RxOverrunFlag)
{
return kStatus_UART_RxHardwareOverrun;
}
if (statusFlag & kUART_NoiseErrorFlag)
{
return kStatus_UART_NoiseError;
}
if (statusFlag & kUART_FramingErrorFlag)
{
return kStatus_UART_FramingError;
}
if (statusFlag & kUART_ParityErrorFlag)
{
return kStatus_UART_ParityError;
}
if( xSemaphoreTake(gs_uartIRQSemBinary, (TickType_t) 0) ){
return kStatus_UART_CharTimeout;
}
}
*(data++) = base->D;
}
return kStatus_Success;
}
Since I am running in a task in Polled mode I do not use the FromISR calls in FreeRTOS. But adding the if(xSemaphoreTake… kills the return buffer even if the length is exactly the length of the string. This I can’t figure out.
Any help would be appreciated.
Should I post this as a formal SR, or is this ok on the community forum?
Thanks
Regards
Robert