Fix reset for leonardo
I found that the previous reset code did not work for Leonardo or Micro, nor did any reset code anywhere on the internet. An examination of the Arduino IDE source code (and the JNI code behind its serial implementation) shows that it holds RTS high and DTR low when doing the 1200 baud open/close. And it turns out that's exactly what's needed!
This commit is contained in:
parent
3dce457c6d
commit
3563d4f245
1 changed files with 2 additions and 2 deletions
|
@ -17,10 +17,10 @@ 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.open()
|
||||
ser.close()
|
||||
ser.setBaudrate(1200)
|
||||
ser.open()
|
||||
ser.setRTS(True) # RTS line needs to be held high and DTR low
|
||||
ser.setDTR(False) # (see Arduino IDE source code)
|
||||
ser.close()
|
||||
sleep(1)
|
||||
|
||||
|
|
Loading…
Reference in a new issue