Created
September 25, 2017 09:22
-
-
Save TheSkorm/8f3c315b7faa1db5d033df12df07763a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 time | |
| import string | |
| failure = "Booting Linux on physical CPU" #this is the string we look for. If we find it we know we need to reset tthe device | |
| ser = serial.Serial('/dev/tty.usbserial-A50285BI',baudrate=115200, bytesize=8, parity='N', stopbits=1, xonxoff=0, rtscts=0, timeout=0.1) | |
| #dtr | |
| def resetDevice(ser): | |
| ser.dtr = False | |
| time.sleep(1) | |
| ser.dtr = True | |
| f = open('/Users/mwheeler/seriallog', 'w') | |
| for key in string.printable: | |
| print "Testing with " + key | |
| data = "" | |
| loops = 0 | |
| while (failure not in data): | |
| loops += 1 | |
| ser.write(key) | |
| data = ser.readline() | |
| print(data) | |
| if loops > 100: #if it takes more than 100 loops before finding the failure then we might have a winner | |
| message = "Found possible escape - " + key + "\n" | |
| print message | |
| f.write(message) | |
| f.flush() | |
| break | |
| print "Key took - " + str(loops) | |
| resetDevice(ser) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment