I have a program using "tirtos_tivac_2_00_01_23" and one function of it is to provide a UART console to accept and respond to commands. I understand the RTOS provide thread safe functions for accessing the UART. Typically this is working well for me except for one case and need some help.
I'm using the following setup;
UART_Params_init(&uartParams);
uartParams.writeMode = UART_MODE_BLOCKING;
uartParams.readMode = UART_MODE_BLOCKING;
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uart = UART_open(Board_UART0, &uartParams);
I have a task that reads one character at a time using "UART_read(uart, &readChar, 1)" then process it as needed. No problem here. I like the way this works because it will block forever until a character is received, keeping the system free for other tasks. This works great for single character ASCII from a terminal.
I now want to process a few multi-character ESC codes such as "up arrow" and "down arrow". What I had in mind was that if I receive an ESC character, enter a special processing thread that waits a couple milliseconds for the rest of the characters to be sent, then read the UART. If it was just an escape char with no other characters I don't want to wait forever. I'd like to have the read return immediately with any characters read, or none if nothing is there.
There are two option I can think of but don't know if either will work. Also if there is a better way, please let me know.
1. Somehow temporarily change the UART readTimeout value from wait forever to some small amount. Can this be done while the UART port is open and in use?
2. Use the TIVA driver function "UARTCharsAvail" to check for available characters before using the RTOS read function. Is it safe to use this function in the RTOS?
Thanks in advance for your help!