串口通信与STM32单片机之间的通信
-
import sensor, image, time import json from pyb import UART sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) sensor.skip_frames(10) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking clock = time.clock() #串口初始化 uart = UART(3,115200) #初始化串口3,波特率115200 uart.init(115200,bits=8,parity=None,stop=1) #8位数据位 无校验位 1位停止 def sending_data(cx,cy): data = ustruct.pack("<bbhhb", 0x2C, 0x12, int(cx), int(cy), 0x3C) uart.write(data); while(True): sending_data(5,4) time.sleep_ms(1000) print(55555)
name 'ustruct' isn't defined如何解决
-
你没有import ustruct