Skip to content

Commit

Permalink
Fix auto-reset on Leonardo-derived boards from Linux hosts
Browse files Browse the repository at this point in the history
Also renamed the touchPort() function, as it's now unambiguously
single-purpose.

The 1200bps reset from Linux hosts wasn't working with these newer
JSSC-based versions. Adding a step which explicitly sets DTR low (via a
TIOCMSET ioctl clearing DTR) fixes this.

I'm fairly sure the reason why this worked on older Arduino with librxtx
and not with jssc is that librxtx appears to keep HUPCL in the termio
flags, but jssc appears to remove it. If HUPCL ("hangup on close") is
set, it causes DTR to be explicitly pulled low on close.
  • Loading branch information
projectgus committed Feb 27, 2015
1 parent 0ae9e3a commit a6909bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
if (verbose)
System.out.println(
I18n.format(_("Forcing reset using 1200bps open/close on port {0}"), uploadPort));
Serial.touchPort(uploadPort, 1200);
Serial.touchForCDCReset(uploadPort);
}
Thread.sleep(400);
if (waitForUploadPort) {
Expand Down
5 changes: 3 additions & 2 deletions arduino-core/src/processing/app/Serial.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ public Serial(String iname) throws SerialException {
new Float(PreferencesData.get("serial.stopbits")).floatValue());
}

public static boolean touchPort(String iname, int irate) throws SerialException {
public static boolean touchForCDCReset(String iname) throws SerialException {
SerialPort serialPort = new SerialPort(iname);
try {
serialPort.openPort();
serialPort.setParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serialPort.setParams(1200, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
serialPort.setDTR(false);
serialPort.closePort();
return true;
} catch (SerialPortException e) {
Expand Down

0 comments on commit a6909bd

Please sign in to comment.