我是用树莓派控制一台刷了Android系统的电脑。
pi@raspberrypi:/ $ python Python 3.7.3 (default, Apr 3 2019, 05:39:12) [GCC 8.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import serial >>> import time >>> ser = serial.Serial( ... port ='/dev/ttyUSB6', ... baudrate=9600, ... parity=serial.PARITY_NONE, ... stopbits=serial.STOPBITS_ONE, ... bytesize=serial.EIGHTBITS, ... timeout=1) >>> ser.write(bytes.fromhex('0000800000000000000000000000000')) Traceback (most recent call last): File "", line 1, in ValueError: non-hexadecimal number found in fromhex() arg at position 31 >>>
右WIN对应的键盘码是8,只有1位,本来按下和释放32位,这少了一位就发送失败了。我也不能加0,8后面加0就变80了,80是声音变大,8前面加0也不对,变成08了,对应键盘码e。
热门产品 :
CH390:以太网控制器芯片