我是用樹(shù)莓派控制一臺(tái)刷了Android系統(tǒng)的電腦。
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對(duì)應(yīng)的鍵盤碼是8,只有1位,本來(lái)按下和釋放32位,這少了一位就發(fā)送失敗了。我也不能加0,8后面加0就變80了,80是聲音變大,8前面加0也不對(duì),變成08了,對(duì)應(yīng)鍵盤碼e。
熱門產(chǎn)品 :
CH32L103: 32位PDUSB低功耗單片機(jī)