aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSudar Muthu <sudar@sudarmuthu.com>2016-02-09 15:28:28 +0530
committerSudar Muthu <sudar@sudarmuthu.com>2016-02-09 15:28:28 +0530
commit5e4c578d758d478ffe701439537b6965e2b5f59e (patch)
treed3a5e09cae8a0fe2d415873c8081e2f87431a8f4 /bin
parent2326da3a5065061d45720e43ad859a2778a5710d (diff)
parent745b520dd6de348c2016a9c699b8590290819195 (diff)
Merge pull request #408 from gauteh/pyserial_3
ard-reset-arduino: support pyserial 3.0
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ard-reset-arduino13
1 files changed, 12 insertions, 1 deletions
diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino
index 3e43486..bca0b03 100755
--- a/bin/ard-reset-arduino
+++ b/bin/ard-reset-arduino
@@ -6,6 +6,12 @@ import os.path
import argparse
from time import sleep
+pyserial_version = None
+try:
+ pyserial_version = int(serial.VERSION[0])
+except:
+ pyserial_version = 2 # less than 2.3
+
parser = argparse.ArgumentParser(description='Reset an Arduino')
parser.add_argument('--caterina', action='store_true', help='Reset a Leonardo, Micro, Robot or LilyPadUSB.')
parser.add_argument('--verbose', action='store_true', help="Watch what's going on on STDERR.")
@@ -17,7 +23,12 @@ 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.setBaudrate(1200)
+
+ if pyserial_version < 3:
+ ser.setBaudRate (1200)
+ else:
+ ser.baudrate = 1200
+
ser.open()
ser.setRTS(True) # RTS line needs to be held high and DTR low
ser.setDTR(False) # (see Arduino IDE source code)