usb-knob/pc-client/main.py

23 lines
555 B
Python

import time
import os
current_path = os.path.dirname(os.path.realpath(__file__))
try:
import serial
except ImportError:
try:
os.system("pip install pyserial")
import serial
except ImportError:
print("Please execute'pip install -r requirements.txt'")
exit()
host = serial.Serial('COM3', 9600)
while True:
try:
output = str(host.readline())
output = output.replace("b'", "")
output = output.replace(str("\r\n'"), "")
print(output)
except KeyboardInterrupt:
exit()