logo

为什么openmv中一加上uart.read()就很卡顿呢?

2019-10-25 16:40
L
清风
import sensor, image, time, ustruct,math
from pyb import UART, LED
uart=UART(3,115200,timeout_char=1000)
uart.init(115200,bits=8,parity=None,stop=1,timeout_char=1000,read_buf_len=200)
while(True):    
       output_str=bytearray([int(1),int(1)])        
       uart.write(output_str)    print(output_str)        
       message_in = uart.read(8)    LED(3).on()        
       if uart.any:    
              print(str(message_in))       
              LED(1).on()        
              print("通讯成功")   
      else:        
              print("发送失败")         
成功发送色块X坐标、色块与摄像头的距离给stm32。
06b429f6-bd87-4aaf-b524-f4ac6a9ba89f.jpg
2019-10-27 14:29
I
网红小智智 星瞳科技

if uart.any:

要加括号调用

if uart.any():