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