2022-08-12 00:15:58 +00:00
|
|
|
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:
|
2022-08-12 00:18:26 +00:00
|
|
|
try:
|
2022-08-12 00:21:38 +00:00
|
|
|
output = str(host.readline())
|
2022-08-12 00:23:56 +00:00
|
|
|
output = output.replace("b'", "")
|
2022-08-12 00:24:08 +00:00
|
|
|
output = output.replace("\r\n'", "")
|
2022-08-12 00:23:56 +00:00
|
|
|
print(output)
|
2022-08-12 00:18:26 +00:00
|
|
|
except KeyboardInterrupt:
|
2022-08-12 00:20:32 +00:00
|
|
|
exit()
|