Tool/software: Code Composer Studio
Hi,
I'm developing an application for TM4C1294NCDPT using TI-RTOS. I'm facing a problem that I know how to solve using TivaWare drivers, but using TI-RTOS drivers for such is being a bit of challenge.
I'm using several UART interfaces and routing my packages to a single task responsible for make any processing required. I decided to make a single reception buffer and when any UART receives any package, I lock such buffer using a semaphore. It's working as described.
The problem I'm facing is when receiving any noise bytes, I fall in a deadlock condition. They way to solve this using TivaWare would be checking if there is any bytes available at UART before entering the UART_read blocking function and implementing a timeout to free the semaphore after a little while.
My question is: is there a fuction inside TI-RTOS to know beforehand if there is any bytes on given UART_Handle? Can I use the UART_Handle in conjunction with UartCharsAvail from Tivaware? How so?
The simplified version of my code is just below:
if(UART_read(uart, &input, 1) == 1) // wait for a single byte { if(Semaphore_pend(semHandle2, 100 / Clock_tickPeriod) == true) // try to aquire the semaphore { syscom->receiveChar(input); // put the received byte inside reception buffer timeout = 3; // set a timeout, which is decremented in another context while((input != EOT) && timeout > 0) // wait for my end of transmission byte or timeout to expire { UART_read(uart, &input, 1); // my routine get stucks here if i dont have any bytes syscom->receiveChar(input); // save my byte on reception buffer } if(input == EOT) { // signaling for another task to process what is in inside the buffer } else { // timeout occorred } syscom->resetRxBuffer(); Semaphore_post(semHandle2); } else // semaphore was already acquired by another uart interface (sit and cry) { System_printf("COM Blocked uart2!\n"); System_flush(); } }