pyserial无法将完整的字节写入串行端口(十六进制数据)

时间:2019-04-03 08:03:55

标签: python python-3.x pyserial

initial.setGravity(Gravity.CENTER_VERTICAL); 会将十六进制写入串行端口,但是在串行端口上仅发送5位。

encode('utf-16')

输出: port = 'COM4' baud = 9600 ser = serial.Serial(port, baud, timeout=1) ser.reset_input_buffer() ser.isOpen() command = '4c 31 32 33' ser.write(bytearray(str(command), 'utf-16')) ser.close() ----------------------------------------- a = ser.readline().decode('utf-16') s = ''.join([chr(int(x, 16)) for x in a.split()])

预期输出:L

0 个答案:

没有答案