为什么不能连续两次进行读取数据,连续两次读取及只能接收65字节。
如果只读取一次就是正常的,但是我的程序需要读一次发一次再读一次发一次这样。
import time
from pyb import UART
uart = UART(3,115200)
uart.init(115200,bits=8,parity=None,stop=1)
while True:
if uart.any():
a=uart.read().decode()
print(a)
time.sleep(1000)
if uart.any():
a=uart.read().decode()
print(a)发送的数据是1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
接收到的只有12345678910111213141516171819202122232425262728293031323334353637
应该如何解决?
加一个timeout_char参数看一下。
uart.init(115200,bits=8,parity=None,stop=1, timeout_char=1000)
@kidswong999 已试过,没用
https://docs.singtown.com/micropython/zh/latest/openmvcam/library/pyb.UART.html
UART.init函数里面,read_buf_len默认是64,改大参数就行。