Use function version of print() for Python 3 compatibility.
This commit is contained in:
parent
392a6b9db1
commit
762f02c0d8
1 changed files with 6 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import serial
|
import serial
|
||||||
import os.path
|
import os.path
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -13,7 +15,7 @@ parser.add_argument('port', nargs=1, help='Serial device e.g. /dev/ttyACM0')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.caterina:
|
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.open()
|
ser.open()
|
||||||
|
@ -24,12 +26,12 @@ if args.caterina:
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
while not os.path.exists(args.port[0]):
|
while not os.path.exists(args.port[0]):
|
||||||
if args.verbose: print 'Waiting for %s to come back' % args.port[0]
|
if args.verbose: print('Waiting for %s to come back' % args.port[0])
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
if args.verbose: print '%s has come back after reset' % args.port[0]
|
if args.verbose: print('%s has come back after reset' % args.port[0])
|
||||||
else:
|
else:
|
||||||
if args.verbose: print 'Setting DTR high on %s for %ss' % (args.port[0],args.period)
|
if args.verbose: print('Setting DTR high on %s for %ss' % (args.port[0], args.period))
|
||||||
ser = serial.Serial(args.port[0], 115200)
|
ser = serial.Serial(args.port[0], 115200)
|
||||||
ser.setDTR(False)
|
ser.setDTR(False)
|
||||||
sleep(args.period)
|
sleep(args.period)
|
||||||
|
|
Loading…
Reference in a new issue