diff options
| author | straccio <lord.strambo@gmail.com> | 2016-06-22 10:52:07 +0200 |
|---|---|---|
| committer | straccio <lord.strambo@gmail.com> | 2016-06-22 10:52:07 +0200 |
| commit | 6c5589bd3ce91b5123088b8f28472605aa327195 (patch) | |
| tree | c4954f993f8eff0124a81efe3aa800e21ddbad5a /bin | |
| parent | e3d97f76f5ce2256c90460719eae19621374cac3 (diff) | |
| parent | c0fea5ccd9d4db662c2a64e8c390d671d138bae7 (diff) | |
Merge remote-tracking branch 'sudar/master'
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/ard-reset-arduino | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino index 3e43486..1f2c7e9 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) |
