BeieliScale/Python/see_serial_output.py

29 lines
550 B
Python
Executable File

#!/usr/bin/python3
from time import sleep
import serial
import sys
exceptions = 0
while (exceptions < 10):
try:
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=1)
except:
exceptions = exceptions + 1
sleep(0.5)
else:
exceptions = 999
if (exceptions != 999):
print("Cannot open Serial Port")
sys.exit()
# Wir leeren den Input Buffer
while True:
try:
while ser.inWaiting():
print(ser.read().decode('utf-8'), end='')
sleep(0.1)
except:
sys.exit()