I'm trying to achieve the same under Windows as I have achieved in Linux environment. Serial to keyboard input, someone please help or point me in the right direction. I'd should be as simple as possible, I tried but failed.
import serial
import time
import uinput
import binascii
ser = serial.Serial(
port='/dev/ttyUSB0',\
baudrate=115200,\
parity=serial.PARITY_NONE,\
stopbits=serial.STOPBITS_ONE,\
bytesize=serial.EIGHTBITS,\
timeout=0)
ser.open()
device = uinput.Device([uinput.KEY_A, uinput.KEY_B])
time.sleep(1)
while True:
datain=ser.read(1)
if datain=='':
continue
datain_int=int(binascii.hexlify(datain), 16)
datain_bin=bin(datain_int)
if datain_int==0:
continue
if datain_int==128:
device.emit_click(uinput.KEY_A)
elif datain_int==64:
device.emit_click(uinput.KEY_B)