为什么通过串口发送条形码payload的内容有时候会报这个错,有时候又不报.
-
codes = img.find_barcodes() for code in codes: img.draw_rectangle(code.rect()) print_args = (barcode_name(code), code.payload(), (180 * code.rotation()) / math.pi, code.quality(), clock.fps()) print("Barcode %s, Payload \"%s\", rotation %f (degrees), quality %d, FPS %f" % print_args) # Message.UartSendData(bytearray([0xAA,0x29,0x05,0x45,0x01,int(code.payload()),0x01])) data =float(code.payload().replace('\ufeff','')) Message.UartSendData(Message.BarDataPack(int(data))) print("条形码发送已完成")
-
原因:因为你的data有时候不是数字的字符串,可能是识别错误。你看串行终端里上面的输出是"‘",不是"1"