ard-reset-arduino: support pyserial 3.0
This commit is contained in:
parent
2326da3a50
commit
745b520dd6
2 changed files with 13 additions and 1 deletions
|
@ -24,6 +24,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
|
||||||
- Fix: Document OSX 1.0/1.6 ARDUINO_DIR differences (https://github.com/thomaskilian)
|
- Fix: Document OSX 1.0/1.6 ARDUINO_DIR differences (https://github.com/thomaskilian)
|
||||||
- Fix: Fix regex to support BOARD_TAGs with hyphens e.g. attiny44-20 (https://github.com/sej7278)
|
- Fix: Fix regex to support BOARD_TAGs with hyphens e.g. attiny44-20 (https://github.com/sej7278)
|
||||||
- Fix: Remove check for BOOTLOADER_PATH, just check for BOOTLOADER_FILE (Issue #402) (https://github.com/sej7278)
|
- Fix: Remove check for BOOTLOADER_PATH, just check for BOOTLOADER_FILE (Issue #402) (https://github.com/sej7278)
|
||||||
|
- Fix: Port ard-reset-arduino to pyserial 3.0 (#407, #408) (https://github.com/gauteh)
|
||||||
|
|
||||||
### 1.5 (2015-04-07)
|
### 1.5 (2015-04-07)
|
||||||
- New: Add support for new 1.5.x library layout (Issue #275) (https://github.com/lukasz-e)
|
- New: Add support for new 1.5.x library layout (Issue #275) (https://github.com/lukasz-e)
|
||||||
|
|
|
@ -6,6 +6,12 @@ import os.path
|
||||||
import argparse
|
import argparse
|
||||||
from time import sleep
|
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 = argparse.ArgumentParser(description='Reset an Arduino')
|
||||||
parser.add_argument('--caterina', action='store_true', help='Reset a Leonardo, Micro, Robot or LilyPadUSB.')
|
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.")
|
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])
|
if args.verbose: print('Forcing reset using 1200bps open/close on port %s' % args.port[0])
|
||||||
ser = serial.Serial(args.port[0], 57600)
|
ser = serial.Serial(args.port[0], 57600)
|
||||||
ser.close()
|
ser.close()
|
||||||
ser.setBaudrate(1200)
|
|
||||||
|
if pyserial_version < 3:
|
||||||
|
ser.setBaudRate (1200)
|
||||||
|
else:
|
||||||
|
ser.baudrate = 1200
|
||||||
|
|
||||||
ser.open()
|
ser.open()
|
||||||
ser.setRTS(True) # RTS line needs to be held high and DTR low
|
ser.setRTS(True) # RTS line needs to be held high and DTR low
|
||||||
ser.setDTR(False) # (see Arduino IDE source code)
|
ser.setDTR(False) # (see Arduino IDE source code)
|
||||||
|
|
Loading…
Reference in a new issue