neptune開發板w800的UART1可以用tls_uart_write發送數據,但是怎麼用tls_uart_read獲取串口發送過來的數據?

發布於 2022-10-27 08:52:38

neptune開發板w800的UART1可以用tls_uart_write發送數據,但是怎麼用tls_uart_read獲取串口發送過來的數據?

case DEMO_MSG_UART_RECEIVE_DATA:

{
    rx_len = uart->rx_data_len;
    while (rx_len > 0)
    {
        printf("\n----1  rx_len----%d", rx_len);
        len = (rx_len > DEMO_UART_RX_BUF_SIZE) ? DEMO_UART_RX_BUF_SIZE : rx_len;
        printf("\n----2  len----%d", len);
        memset(uart->rx_buf, 0, (DEMO_UART_RX_BUF_SIZE + 1));
        tls_uart_read(TLS_UART_1, msg_rxfifo_buf, len);
        tls_uart_read(TLS_UART_1, rx_fifo_buf1[0], len);
        printf("\n----####  msg_rxfifo_buf----%s\n", msg_rxfifo_buf);
        printf("\n----####  rx_fifo_buf1[0]----%s\n", rx_fifo_buf1[0]);
        ret = tls_uart_read(TLS_UART_1, (u8 *)uart->rx_buf, len);
        ret = tls_uart_read(TLS_UART_1, (u8 *)uart->rx_buf, len); /* input */
        printf("\n----####  DEMO_MSG_UART_RECEIVE_DATA----%s\n", uart->rx_buf);
        printf("\n----3  ret----%d", ret);

        if (ret <= 0)
        {
            break;
        }

        rx_len -= ret;
        uart->rx_data_len -= ret;

if USE_DMA_TX_FTR

        // tls_uart_dma_write(uart->rx_buf, len, uart_dma_done, TLS_UART_1);

else

        tls_uart_write(TLS_UART_1, uart->rx_buf, len); /* output */
        printf("\n----4  DEMO_MSG_UART_RECEIVE_DATA  uart->rx_buf----%s\n", uart->rx_buf);

endif

    }
    printf("\n----5  DEMO_MSG_UART_RECEIVE_DATA  uart->rx_msg_num----%s\n", uart->rx_msg_num);
    if (uart->rx_msg_num > 0)
    {
        uart->rx_msg_num--;
    }

    printf("\n----6  DEMO_MSG_UART_RECEIVE_DATA----%s\n", uart->rx_buf);
}
break;

代碼用的是開發板自帶的wm_uart_demo.c
我修改了下,運行得不到發送過來的1234

image.png

查看更多

關注者
0
被浏覽
2.4k
2 個回答
ZYQ
ZYQ 2022-10-27
我已不再支持W80X任何相關問題的回複,請大家不要私信,有問題找 isme 謝謝

直接調用不就好了,只要有數據就可以讀取到,或者調用tls_uart_try_read

hitiger
hitiger 2022-10-27
這家夥很懶,什麼也沒寫!

case DEMO_MSG_UART_RECEIVE_DATA:

    {
        rx_len = uart->rx_data_len;
        while (rx_len > 0)
        {
            printf("\n----1  rx_len----%d", rx_len);
            len = (rx_len > DEMO_UART_RX_BUF_SIZE) ? DEMO_UART_RX_BUF_SIZE : rx_len;
            printf("\n----2  len----%d", len);
            memset(uart->rx_buf, 0, (DEMO_UART_RX_BUF_SIZE + 1));
            tls_uart_read(TLS_UART_1, msg_rxfifo_buf, len);
            tls_uart_read(TLS_UART_1, rx_fifo_buf1[0], len);
            printf("\n----####  msg_rxfifo_buf----%s\n", msg_rxfifo_buf);
            printf("\n----####  rx_fifo_buf1[0]----%s\n", rx_fifo_buf1[0]);
            ret = tls_uart_read(TLS_UART_1, (u8 *)uart->rx_buf, len);
            ret = tls_uart_read(TLS_UART_1, (u8 *)uart->rx_buf, len); /* input */
            printf("\n----####  DEMO_MSG_UART_RECEIVE_DATA----%s\n", uart->rx_buf);
            printf("\n----3  ret----%d", ret);

            if (ret <= 0)
            {
                break;
            }

            rx_len -= ret;
            uart->rx_data_len -= ret;

if USE_DMA_TX_FTR

            // tls_uart_dma_write(uart->rx_buf, len, uart_dma_done, TLS_UART_1);

else

            tls_uart_write(TLS_UART_1, uart->rx_buf, len); /* output */
            printf("\n----4  DEMO_MSG_UART_RECEIVE_DATA  uart->rx_buf----%s\n", uart->rx_buf);

endif

        }
        printf("\n----5  DEMO_MSG_UART_RECEIVE_DATA  uart->rx_msg_num----%s\n", uart->rx_msg_num);
        if (uart->rx_msg_num > 0)
        {
            uart->rx_msg_num--;
        }

        printf("\n----6  DEMO_MSG_UART_RECEIVE_DATA----%s\n", uart->rx_buf);
    }
    break;
    
    代碼用的是開發板自帶的wm_uart_demo.c
    我修改了下,運行得不到發送過來的1234
   

image.png

撰寫答案

請登錄後再發布答案,點擊登錄

發布
問題

分享
好友

手機
浏覽

掃碼手機浏覽