Permalink
Cannot retrieve contributors at this time
Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upavrdude-rpi/autoreset /
Go to file| #!/usr/bin/python | |
| import RPi.GPIO as GPIO | |
| import sys, os, re, time, fcntl | |
| fd = sys.stdin.fileno() | |
| fl = fcntl.fcntl(fd, fcntl.F_GETFL) | |
| fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) | |
| GPIO.setmode(GPIO.BOARD) | |
| dtr = re.compile('.+TIOCM_DTR.+') | |
| start = time.time() | |
| def reset(): | |
| pin = 11 | |
| GPIO.setup(pin, GPIO.OUT) | |
| GPIO.output(pin, GPIO.HIGH) | |
| time.sleep(0.12) | |
| GPIO.output(pin, GPIO.LOW) | |
| def process(): | |
| while True: | |
| try: | |
| duration = time.time() - start | |
| input = sys.stdin.readline().strip() | |
| if dtr.match(input): | |
| reset() | |
| return | |
| elif duration > 5000: | |
| return | |
| except: | |
| continue | |
| process() | |
| print "done with autoreset" |