logo

为什么串口接受的数据始终是一个一个的字符?

2023-07-24 12:08
6
xbaw
beddcdcc-90e6-427c-b4b7-e5027ad8c183.png
5a9632ae-2f99-42f8-bd15-656af0917efa.png
a539f1a6-b5fe-44c8-9af6-423828bc142d.png
# UART Control
#
# This example shows how to use the serial port on your OpenMV Cam. Attach pin
# P4 to the serial input of a serial LCD screen to see "Hello World!" printed
# on the serial LCD display.

import time
from pyb import UART

# Always pass UART 3 for the UART number for your OpenMV Cam.
# The second argument is the UART baud rate. For a more advanced UART control
# example see the BLE-Shield driver.
uart = UART(3, 19200, timeout_char=1000)

while(True):
    if uart.any():
        a = uart.readline().decode().strip()     
        print(a)
2023-07-24 18:50
I
网红小智智 星瞳科技

串口助手最后加上\r\n