v3.9.2版本串口无法使用?
-
openmv4p + mt9v034模块 使用v3.9.2固件版本,其他硬件使用 ttl转rs232模块 连接串口转wifi硬件模块出现串口无法使用的问题,即无法发送与接收。刷上固件版本v3.6.8 串口发送和接收可正常使用
# QRCode Example # # This example shows the power of the OpenMV Cam to detect QR Codes # using lens correction (see the qrcodes_with_lens_corr.py script for higher performance). import sensor, image, time ,tv from pyb import UART from pyb import Pin, Timer sensor.reset() sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) # must turn this off to prevent image washout... clock = time.clock() uart = UART(3, 19200) tv.init() # 初始化tv # 50kHz pin6 timer2 channel1 #light = Timer(2, freq=18000).channel(1, Timer.PWM, pin=Pin("P6")) #light.pulse_width_percent(100) # adjust light 0~100 while(True): clock.tick() img = sensor.snapshot() #使用无畸变镜头 #img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens. for code in img.find_qrcodes(): img.draw_rectangle(code.rect(), color = (255, 0, 0)) print(code.payload()) if code.payload() is not None : uart.write(code.payload() + "\r") tv.display(img) if uart.any() : a = uart.readline().decode() print(a) # print(clock.fps())
使用v3.9.2版本 单独测试串口 也是无法接收与发送 使用v3.6.8版本可以正常接收发送
import time from pyb import UART uart = UART(3, 19200) while(True): uart.write("Hello World!\r") if uart.any() : a = uart.readline().decode() print(a))
-
uart = UART(3, 19200)
改为
uart = UART(3,19200, timeout=1000)