Skip to content

Commit 745b520

Browse files
committed
ard-reset-arduino: support pyserial 3.0
1 parent 2326da3 commit 745b520

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
2424
- Fix: Document OSX 1.0/1.6 ARDUINO_DIR differences (https://github.com/thomaskilian)
2525
- Fix: Fix regex to support BOARD_TAGs with hyphens e.g. attiny44-20 (https://github.com/sej7278)
2626
- Fix: Remove check for BOOTLOADER_PATH, just check for BOOTLOADER_FILE (Issue #402) (https://github.com/sej7278)
27+
- Fix: Port ard-reset-arduino to pyserial 3.0 (#407, #408) (https://github.com/gauteh)
2728

2829
### 1.5 (2015-04-07)
2930
- New: Add support for new 1.5.x library layout (Issue #275) (https://github.com/lukasz-e)

bin/ard-reset-arduino

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import os.path
66
import argparse
77
from time import sleep
88

9+
pyserial_version = None
10+
try:
11+
pyserial_version = int(serial.VERSION[0])
12+
except:
13+
pyserial_version = 2 # less than 2.3
14+
915
parser = argparse.ArgumentParser(description='Reset an Arduino')
1016
parser.add_argument('--caterina', action='store_true', help='Reset a Leonardo, Micro, Robot or LilyPadUSB.')
1117
parser.add_argument('--verbose', action='store_true', help="Watch what's going on on STDERR.")
@@ -17,7 +23,12 @@ if args.caterina:
1723
if args.verbose: print('Forcing reset using 1200bps open/close on port %s' % args.port[0])
1824
ser = serial.Serial(args.port[0], 57600)
1925
ser.close()
20-
ser.setBaudrate(1200)
26+
27+
if pyserial_version < 3:
28+
ser.setBaudRate (1200)
29+
else:
30+
ser.baudrate = 1200
31+
2132
ser.open()
2233
ser.setRTS(True) # RTS line needs to be held high and DTR low
2334
ser.setDTR(False) # (see Arduino IDE source code)

0 commit comments

Comments
 (0)