Initial commit
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/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()
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/python3
|
||||
from time import sleep
|
||||
import serial
|
||||
import sys
|
||||
|
||||
arg1 = sys.argv[1] + "\n"
|
||||
|
||||
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()
|
||||
|
||||
|
||||
sleep(0.1)
|
||||
# Wir leeren den Input Buffer
|
||||
while ser.inWaiting():
|
||||
#print("AAA: "+ser.readline().decode('utf-8'), end='')
|
||||
ser.readline()
|
||||
|
||||
ser.write(arg1.encode('utf-8'))
|
||||
sleep(0.1)
|
||||
ch=" "
|
||||
while (ch != b'}'):
|
||||
try:
|
||||
data_available = ser.inWaiting()
|
||||
except:
|
||||
sys.exit()
|
||||
else:
|
||||
while data_available:
|
||||
try:
|
||||
ch=ser.read()
|
||||
except:
|
||||
sys.exit()
|
||||
else:
|
||||
print(ch.decode('utf-8'), end='')
|
||||
if ch == b'}':
|
||||
print()
|
||||
sys.exit()
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/python3
|
||||
from time import sleep
|
||||
import serial
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
while (True):
|
||||
serial_not_open = True
|
||||
while serial_not_open:
|
||||
try:
|
||||
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=1)
|
||||
except:
|
||||
sleep(0.5)
|
||||
else:
|
||||
serial_not_open = False
|
||||
|
||||
no_exception = True
|
||||
while no_exception:
|
||||
try:
|
||||
while True:
|
||||
while ser.inWaiting():
|
||||
print(ser.read().decode('utf-8'), end='')
|
||||
sleep(0.1)
|
||||
except:
|
||||
print(datetime.datetime.now().strftime("%d.%m.%Y %H:%M:%S")," - Serial Device disappeared...")
|
||||
ser.close()
|
||||
no_exception = False
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/python3
|
||||
from time import sleep
|
||||
import serial
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
while (True):
|
||||
serial_not_open = True
|
||||
while serial_not_open:
|
||||
try:
|
||||
ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=1)
|
||||
except:
|
||||
sleep(0.5)
|
||||
else:
|
||||
serial_not_open = False
|
||||
|
||||
no_exception = True
|
||||
while no_exception:
|
||||
try:
|
||||
while True:
|
||||
while ser.inWaiting():
|
||||
print(ser.read().decode('utf-8'), end='')
|
||||
sleep(0.1)
|
||||
except:
|
||||
print(datetime.datetime.now().strftime("%d.%m.%Y %H:%M:%S")," - Serial Device disappeared...")
|
||||
ser.close()
|
||||
no_exception = False
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/python3
|
||||
from time import sleep
|
||||
import serial
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
while (True):
|
||||
serial_not_open = True
|
||||
while serial_not_open:
|
||||
try:
|
||||
ser = serial.Serial('/dev/ttyUSB1', 115200, timeout=1)
|
||||
except:
|
||||
sleep(0.5)
|
||||
else:
|
||||
serial_not_open = False
|
||||
|
||||
no_exception = True
|
||||
while no_exception:
|
||||
try:
|
||||
while True:
|
||||
while ser.inWaiting():
|
||||
print(ser.read().decode('utf-8'), end='')
|
||||
sleep(0.1)
|
||||
except:
|
||||
print(datetime.datetime.now().strftime("%d.%m.%Y %H:%M:%S")," - Serial Device disappeared...")
|
||||
ser.close()
|
||||
no_exception = False
|
||||
Reference in New Issue
Block a user