1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

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.
This commit is contained in:
Angus Gratton 2015-02-27 10:47:43 +11:00
parent 0ae9e3a0d0
commit a6909bdb49
2 changed files with 4 additions and 3 deletions

View File

@ -116,7 +116,7 @@ public class SerialUploader extends Uploader {
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) {

View File

@ -80,11 +80,12 @@ public class Serial implements SerialPortEventListener {
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) {