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.

RTOS/LAUNCHXL-CC1310: CC1310 uartecho

Part Number: LAUNCHXL-CC1310


Tool/software: TI-RTOS

Hello Sir,

I want to know how to time out form the uart read.  I setup the example name "uartecho"

source code

/* Loop forever echoing */
    while (1) {

        UART_read(uart, &input, 1);

        UART_write(uart, &input, 1);
    }
}

Thank you for your help

James

  • James,

    The uartecho example uses the default transfer mode of UART_MODE_BLOCKING.  For blocking mode the default timeout is UART_WAIT_FOREVER, which means the read will never timeout.  But you can specify a different readTimeout parameter when you open the UART.  For example:

        UART_Params_init(&uartParams);
        uartParams.writeDataMode = UART_DATA_BINARY;
        uartParams.readDataMode = UART_DATA_BINARY;
        uartParams.readReturnMode = UART_RETURN_FULL;
        uartParams.readEcho = UART_ECHO_OFF;
        uartParams.readTimeout = your_timeout_in_microseconds / Clock_tickPeriod;
        uartParams.baudRate = 9600;
        uart = UART_open(Board_UART0, &uartParams);

    Another option is to use UART_MODE_CALLBACK, where the UART_read() call will return immediately, and there will be a callback upon read completion.  Using this you can implement your own timeout logic, and call UART_readCancel() when you want to cancel the pending read.

    Regards,
    Scott

  • There was a suggested answer and since there has been no active on this thread for more than a week, the suggested answer was marked as verify. Please feel free to select the "Reject Answer" button and reply with more details.