uart = UART(3, 115200)
uart.init(115200, bits=8, parity=None, stop=1) # init with given parameters
def send_data_packet(x,y,z,w):
#frame=[0x2C,18,cx%0xff,int(cx/0xff),cy%0xff,int(cy/0xff),0x5B];
#data = bytearray(frame)
data = ustruct.pack("<bbhhhhb", #格式为俩个字符俩个短整型(2字节)
0x2C, #帧头1
0x12, #帧头2
int(cx), # up sample by 4 #数据1
int(cy), # up sample by 4 #数据2
int(cw), # up sample by 4 #数据1
int(ch), # up sample by 4 #数据2
0x5B)
uart.write(data);data_out = json.dumps(set(data))
while(True):
clock.tick()
date=bytearray[(1,2,3,4,5)]
uart.write(data)
time.sleep(1)
运行这个测试。