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.

关于CC3220SF 的uartecho 例程我无法读取Rx 的数据?



1.我使用uartecho 驱动发送数据给传感器,传感器正常响应回发了数据,但是我uart_read 函数时程序阻塞在uart_read函数,我想知道uart_read函数的阻塞条件是什么原因造成的?

  • /*!
     *  @brief  Function that reads data from a UART with interrupt enabled.
     *
     *  %UART_read() reads data from a UART controller. The destination is specified
     *  by \a buffer and the number of bytes to read is given by \a size.
     *
     *  In #UART_MODE_BLOCKING, %UART_read() blocks task execution until all
     *  the data in buffer has been read.
     *
     *  In #UART_MODE_CALLBACK, %UART_read() does not block task execution.
     *  Instead, a callback function specified by UART_Params::readCallback
     *  is called when the transfer is finished.
     *  The callback function can occur in the caller's context or in HWI or SWI
     *  context, depending on the device-specific implementation.
     *  An unfinished asynchronous read operation must always be canceled using
     *  UART_readCancel() before calling UART_close().
     *
     *  %UART_read() is mutually exclusive to UART_readPolling(). For an opened
     *  UART peripheral, either %UART_read() or UART_readPolling() can be used,
     *  but not both.
     *
     *  @sa UART_readPolling()
     *
     *  @param  handle      A #UART_Handle returned by UART_open()
     *
     *  @param  buffer      A pointer to an empty buffer to which
     *                      received data should be written
     *
     *  @param  size        The number of bytes to be written into buffer
     *
     *  @return Returns the number of bytes that have been read from the UART,
     *          #UART_STATUS_ERROR on an error.
     */
    extern int_fast32_t UART_read(UART_Handle handle, void *buffer, size_t size);

  • 我发现uart_read 函数是否是读取uart Rx线上的数据,uartecho例程调用uart_read函数等待键盘的输入,在发送给终端XDS110
  • Lease 说:
    uartecho例程调用uart_read函数等待键盘的输入,在发送给终端XDS110

    是的

  • 我传感器回发的的数据是二进制数,并没有换行符和新行,所以uart一直是阻塞的,那如何设置UART接收二进制数在不遇到、换行符就返回呢?

  • 使用UART_DATA_BINARY,数据按原样传递,不进行任何处理。
    使用UART_DATA_TEXT才需要换行符