Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
simple script which reopens same tty
import serial
import struct
import sys
import time
def open_and_cat():
port = serial.Serial(sys.argv[1], sys.argv[2], bytesize=8, parity='N', stopbits=1, xonxoff=0, rtscts=0, timeout=2)
while True:
data = port.read(1)
if len(data)!=0:
sys.stdout.write(data)
sys.stdout.flush()
while True:
try:
open_and_cat()
except:
print "error on port, trying again"
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.