Skip to content

Commit a6909bd

Browse files
committed
Fix auto-reset on Leonardo-derived boards from Linux hosts
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.
1 parent 0ae9e3a commit a6909bd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
116116
if (verbose)
117117
System.out.println(
118118
I18n.format(_("Forcing reset using 1200bps open/close on port {0}"), uploadPort));
119-
Serial.touchPort(uploadPort, 1200);
119+
Serial.touchForCDCReset(uploadPort);
120120
}
121121
Thread.sleep(400);
122122
if (waitForUploadPort) {

arduino-core/src/processing/app/Serial.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ public Serial(String iname) throws SerialException {
8080
new Float(PreferencesData.get("serial.stopbits")).floatValue());
8181
}
8282

83-
public static boolean touchPort(String iname, int irate) throws SerialException {
83+
public static boolean touchForCDCReset(String iname) throws SerialException {
8484
SerialPort serialPort = new SerialPort(iname);
8585
try {
8686
serialPort.openPort();
87-
serialPort.setParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
87+
serialPort.setParams(1200, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
88+
serialPort.setDTR(false);
8889
serialPort.closePort();
8990
return true;
9091
} catch (SerialPortException e) {

0 commit comments

Comments
 (0)