aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin Li <calvin.li.lt@gmail.com>2015-04-03 22:37:51 -0700
committerSudar <sudar@sudarmuthu.com>2015-04-04 16:08:23 +0530
commitbc2a9a9798879694f6575c0d003cc7867a3d9e66 (patch)
tree667b230657864ffc0e9656af44d284ebcb442d08
parent3dce457c6df6bc7b3c3ae9d357d7f3b802a297a0 (diff)
Fix reset for leonardo
I found that the previous reset code did not work for Leonardo or Micro, nor did any reset code anywhere on the internet. An examination of the Arduino IDE source code (and the JNI code behind its serial implementation) shows that it holds RTS high and DTR low when doing the 1200 baud open/close. And it turns out that's exactly what's needed!
-rw-r--r--HISTORY.md1
-rwxr-xr-xbin/ard-reset-arduino4
2 files changed, 3 insertions, 2 deletions
diff --git a/HISTORY.md b/HISTORY.md
index 6705cba..15ab502 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -53,6 +53,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
- Fix: Can now find IDE 1.5+ preferences.txt on Linux and Mac (https://github.com/sej7278)
- Fix: Added support for VARIANT being a submenu item in 1.6 cores like attiny (https://github.com/sej7278)
- Fix: Replaced copyright symbol causing sed problems on OSX (Issue #335). (https://github.com/sej7278)
+- Fix: Fix issues with resetting Leonardo and Micro boards(Issue #340) (https://github.com/calvinli)
### 1.3.4 (2014-07-12)
- Tweak: Allow spaces in "Serial.begin (....)". (Issue #190) (https://github.com/pdav)
diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino
index ed22a63..3e43486 100755
--- a/bin/ard-reset-arduino
+++ b/bin/ard-reset-arduino
@@ -17,10 +17,10 @@ if args.caterina:
if args.verbose: print('Forcing reset using 1200bps open/close on port %s' % args.port[0])
ser = serial.Serial(args.port[0], 57600)
ser.close()
- ser.open()
- ser.close()
ser.setBaudrate(1200)
ser.open()
+ ser.setRTS(True) # RTS line needs to be held high and DTR low
+ ser.setDTR(False) # (see Arduino IDE source code)
ser.close()
sleep(1)