aboutsummaryrefslogtreecommitdiffstats
path: root/reset.py
diff options
context:
space:
mode:
authorAJM <poslathian@poslathian.(none)>2010-04-25 18:23:40 -0400
committerbnewbold <bnewbold@robocracy.org>2010-05-20 22:09:16 -0400
commit3d0c8c9b374a9a2e3e9fb296cf8a89239106eea2 (patch)
treea9b937681146845c5cc95f9d52c81b76c8d7cd35 /reset.py
parentba9ff3861bbcc17c78086b1887691c324f13ba0e (diff)
downloadlibrambutan-3d0c8c9b374a9a2e3e9fb296cf8a89239106eea2.tar.gz
librambutan-3d0c8c9b374a9a2e3e9fb296cf8a89239106eea2.zip
added reset.py to the makefile and the build dir
Diffstat (limited to 'reset.py')
-rwxr-xr-xreset.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/reset.py b/reset.py
new file mode 100755
index 0000000..a7447d0
--- /dev/null
+++ b/reset.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+
+import serial
+import time
+
+ser = serial.Serial('/dev/ttyACM0', baudrate=115200)
+ser.open()
+
+# pull dtr and rts low
+ser.setRTS(0)
+ser.setDTR(0)
+
+# toggle DTR
+ser.setDTR(1)
+
+# Some versions of python seem to throw an IOError on this line.
+# I have no idea why and don't have any time to look at it.
+# Just catch it for now.
+#
+# Error msg:
+#
+# Traceback (most recent call last):
+# File "./reset.py", line 15, in <module>
+# ser.setDTR(0)
+# File "/usr/lib/python2.6/dist-packages/serial/serialposix.py", line 388, in setDTR
+# fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_DTR_str)
+# IOError: [Errno 84] Invalid or incomplete multibyte or wide character
+
+try:
+ ser.setDTR(0)
+except IOError:
+ print "IOError caught"
+
+# close
+ser.close()
+
+time.sleep(1)
+
+print "Done"