Skip to content

Commit 125846f

Browse files
d-a-vcmaglie
authored andcommitted
per-board generic option in config file boards.txt for disabling control of dtr+rts from IDE, allowing board specific use of these lines for example for reset or programming mode. Currently used by esp8266/Arduino.
1 parent c7b412c commit 125846f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Diff for: arduino-core/src/processing/app/Serial.java

+14-6
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,35 @@ public Serial() throws SerialException {
6464
PreferencesData.getInteger("serial.debug_rate", 9600),
6565
PreferencesData.getNonEmpty("serial.parity", "N").charAt(0),
6666
PreferencesData.getInteger("serial.databits", 8),
67-
PreferencesData.getFloat("serial.stopbits", 1));
67+
PreferencesData.getFloat("serial.stopbits", 1),
68+
!BaseNoGui.getBoardPreferences().get("serial.disableRTS").equalsIgnoreCase("true"),
69+
!BaseNoGui.getBoardPreferences().get("serial.disableDTR").equalsIgnoreCase("true"));
6870
}
6971

7072
public Serial(int irate) throws SerialException {
7173
this(PreferencesData.get("serial.port"), irate,
7274
PreferencesData.getNonEmpty("serial.parity", "N").charAt(0),
7375
PreferencesData.getInteger("serial.databits", 8),
74-
PreferencesData.getFloat("serial.stopbits", 1));
76+
PreferencesData.getFloat("serial.stopbits", 1),
77+
!BaseNoGui.getBoardPreferences().get("serial.disableRTS").equalsIgnoreCase("true"),
78+
!BaseNoGui.getBoardPreferences().get("serial.disableDTR").equalsIgnoreCase("true"));
7579
}
7680

7781
public Serial(String iname, int irate) throws SerialException {
7882
this(iname, irate, PreferencesData.getNonEmpty("serial.parity", "N").charAt(0),
7983
PreferencesData.getInteger("serial.databits", 8),
80-
PreferencesData.getFloat("serial.stopbits", 1));
84+
PreferencesData.getFloat("serial.stopbits", 1),
85+
!BaseNoGui.getBoardPreferences().get("serial.disableRTS").equalsIgnoreCase("true"),
86+
!BaseNoGui.getBoardPreferences().get("serial.disableDTR").equalsIgnoreCase("true"));
8187
}
8288

8389
public Serial(String iname) throws SerialException {
8490
this(iname, PreferencesData.getInteger("serial.debug_rate", 9600),
8591
PreferencesData.getNonEmpty("serial.parity", "N").charAt(0),
8692
PreferencesData.getInteger("serial.databits", 8),
87-
PreferencesData.getFloat("serial.stopbits", 1));
93+
PreferencesData.getFloat("serial.stopbits", 1),
94+
!BaseNoGui.getBoardPreferences().get("serial.disableRTS").equalsIgnoreCase("true"),
95+
!BaseNoGui.getBoardPreferences().get("serial.disableDTR").equalsIgnoreCase("true"));
8896
}
8997

9098
public static boolean touchForCDCReset(String iname) throws SerialException {
@@ -108,7 +116,7 @@ public static boolean touchForCDCReset(String iname) throws SerialException {
108116
}
109117
}
110118

111-
private Serial(String iname, int irate, char iparity, int idatabits, float istopbits) throws SerialException {
119+
private Serial(String iname, int irate, char iparity, int idatabits, float istopbits, boolean setRTS, boolean setDTR) throws SerialException {
112120
//if (port != null) port.close();
113121
//this.parent = parent;
114122
//parent.attach(this);
@@ -126,7 +134,7 @@ private Serial(String iname, int irate, char iparity, int idatabits, float istop
126134
try {
127135
port = new SerialPort(iname);
128136
port.openPort();
129-
boolean res = port.setParams(irate, idatabits, stopbits, parity, true, true);
137+
boolean res = port.setParams(irate, idatabits, stopbits, parity, setRTS, setDTR);
130138
if (!res) {
131139
System.err.println(format(tr("Error while setting serial port parameters: {0} {1} {2} {3}"),
132140
irate, iparity, idatabits, istopbits));

0 commit comments

Comments
 (0)