This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART_control(Uart_handle[1],UART_CMD_GETRXCOUNT,&count) not working EK-TM4C123

Hi

I am attempting to read from the UART that has been previously opened. In order that my task does not block, I am trying to get the no of characters

in the buffer, before doing a UART_readPolling which is called only if count is >0, but count is always returning zero after call to UART_control even when I am

sending data from a terminal. However UART_readPolling is working satisfactorily when called by itself (when check on count is removed) . It blocks till a

character is received and then returns the character.

UART is opened in UART_MODE_BLOCKING. Please advise.

Regards

  • Hi Nikhil,

    Nikhil Kant said:

    before doing a UART_readPolling which is called only if count is >0, but count is always returning zero after call to UART_control

    Just wanted to make sure you are not looking at the return value of UART_control() but the value of the count variable that is passed as an argument to UART_control(). UART_control() will return 0 on success so its return value will always be 0.

    Can you share your application so I can run it and repro the problem on my end ?

    Best,

    Ashish

  • Hi Ashish,
    This problem is already solved. My project was linking into TI-RTOS 2_10 in which the function UART control is not implemented, though the declaration and function body is present in UARTTiva.c. I was looking at docs of TI-RTOS 2_12.
    Migrating my project to TI-RTO2_12 solved the problem. The code snippet is given below:

    UART_control(Uart_Handle[1],UART_CMD_GETRXCOUNT,&count);
    If (count>0) {
    UART_read(Uart_Handle[1], (void *)&c, 1);//read character
    UART_writePolling(Uart_Handle[1], &c, 1);//echo to terminal
    }
    Task_yield();