Created
December 3, 2012 09:35
-
-
Save snegovick/4193874 to your computer and use it in GitHub Desktop.
simple script which reopens same tty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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