Skip to content

Commit c1b2015

Browse files
author
jantje
committed
#1353 only reset when touch is set
1 parent 7a67aca commit c1b2015

File tree

1 file changed

+38
-61
lines changed

1 file changed

+38
-61
lines changed

io.sloeber.core/src/io/sloeber/core/communication/ArduinoSerial.java

+38-61
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
import io.sloeber.core.api.Serial;
1515
import io.sloeber.core.common.Common;
1616
import io.sloeber.core.common.Const;
17-
@SuppressWarnings("unused")
1817
public class ArduinoSerial {
19-
private static final String MS=Messages.MS;
18+
private static final String MS=Messages.MS_TAG;
2019

21-
private static final String PORT=Messages.PORT;
20+
private static final String PORT=Messages.PORT_TAG;
2221

2322
private ArduinoSerial() {
2423
}
@@ -174,20 +173,15 @@ private static boolean wait_for_com_Port_to_appear(String comPort) {
174173
* the time to wait between the 2 toggle commands
175174
* @return true is successful otherwise false
176175
*/
177-
private static boolean ToggleDTR(Serial serialPort, long delay) {
178-
serialPort.setDTR(false);
179-
serialPort.setRTS(false);
180-
181-
try {
182-
Thread.sleep(delay);
183-
} catch (InterruptedException e) {// Jaba is not going to write this
184-
// code
185-
}
186-
187-
serialPort.setDTR(true);
188-
serialPort.setRTS(true);
189-
return true;
190-
}
176+
/*
177+
* private static boolean ToggleDTR(Serial serialPort, long delay) {
178+
* serialPort.setDTR(false); serialPort.setRTS(false);
179+
*
180+
* try { Thread.sleep(delay); } catch (InterruptedException e) {// Jaba is not
181+
* going to write this // code }
182+
*
183+
* serialPort.setDTR(true); serialPort.setRTS(true); return true; }
184+
*/
191185

192186
/**
193187
* reset the arduino
@@ -212,17 +206,7 @@ public static String makeArduinoUploadready(MessageConsoleStream console, IProje
212206
.equalsIgnoreCase(Const.TRUE);
213207
String comPort = boardDescriptor.getActualUploadPort();
214208

215-
216-
boolean bResetPortForUpload = Common
217-
.getBuildEnvironmentVariable(confDesc, Const.ENV_KEY_RESET_BEFORE_UPLOAD, Const.FALSE)
218-
.equalsIgnoreCase(Const.TRUE);
219-
220-
/*
221-
* Teensy uses halfkay protocol and does not require a reset in
222-
* boards.txt use Const.ENV_KEY_RESET_BEFORE_UPLOAD=FALSE to disable a
223-
* reset
224-
*/
225-
if (!bResetPortForUpload || "teensyloader".equalsIgnoreCase(boardDescriptor.getuploadTool())) { //$NON-NLS-1$
209+
if (!use_1200bps_touch) {
226210
return comPort;
227211
}
228212
/*
@@ -235,7 +219,6 @@ public static String makeArduinoUploadready(MessageConsoleStream console, IProje
235219
console.println(Messages.ArduinoSerial_comport_not_found + ' ' + comPort);
236220
return comPort;
237221
}
238-
if (use_1200bps_touch) {
239222
// Get the list of the current com serial ports
240223
console.println(Messages.ArduinoSerial_Using_1200bps_touch.replace(PORT, comPort));
241224

@@ -260,37 +243,31 @@ public static String makeArduinoUploadready(MessageConsoleStream console, IProje
260243
console.println(Messages.ArduinoSerial_Continuing_to_use.replace(PORT, comPort));
261244
console.println(Messages.ArduinoSerial_Ending_reset);
262245
return comPort;
263-
}
264-
265-
// connect to the serial port
266-
console.println(Messages.ArduinoSerial_reset_dtr_toggle);
267-
Serial serialPort;
268-
try {
269-
serialPort = new Serial(comPort, 9600);
270-
} catch (Exception e) {
271-
e.printStackTrace();
272-
String error=Messages.ArduinoSerial_exception_while_opening_seral_port.replace(PORT,comPort);
273-
Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID,error, e));
274-
console.println(error);
275-
console.println(Messages.ArduinoSerial_Continuing_to_use.replace(PORT, comPort));
276-
console.println(Messages.ArduinoSerial_Ending_reset);
277-
return comPort;
278-
}
279-
if (!serialPort.IsConnected()) {
280-
Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID,
281-
Messages.ArduinoSerial_unable_to_open_serial_port.replace(PORT,comPort) + comPort, null));
282-
console.println(Messages.ArduinoSerial_exception_while_opening_seral_port.replace(PORT,comPort) );
283-
console.println(Messages.ArduinoSerial_Continuing_to_use.replace(PORT,comPort));
284-
console.println(Messages.ArduinoSerial_Ending_reset);
285-
return comPort;
286-
}
287-
288-
ToggleDTR(serialPort, 100);
289-
290-
serialPort.dispose();
291-
console.println(Messages.ArduinoSerial_Continuing_to_use.replace(PORT, comPort));
292-
console.println(Messages.ArduinoSerial_Ending_reset);
293-
return comPort;
294-
246+
/*
247+
* this code should be dead code // connect to the serial port
248+
* console.println(Messages.ArduinoSerial_reset_dtr_toggle); Serial serialPort;
249+
* try { serialPort = new Serial(comPort, 9600); } catch (Exception e) {
250+
* e.printStackTrace(); String
251+
* error=Messages.ArduinoSerial_exception_while_opening_seral_port.replace(PORT,
252+
* comPort); Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID,error,
253+
* e)); console.println(error);
254+
* console.println(Messages.ArduinoSerial_Continuing_to_use.replace(PORT,
255+
* comPort)); console.println(Messages.ArduinoSerial_Ending_reset); return
256+
* comPort; } if (!serialPort.IsConnected()) { Common.log(new
257+
* Status(IStatus.WARNING, Const.CORE_PLUGIN_ID,
258+
* Messages.ArduinoSerial_unable_to_open_serial_port.replace(PORT,comPort) +
259+
* comPort, null));
260+
* console.println(Messages.ArduinoSerial_exception_while_opening_seral_port.
261+
* replace(PORT,comPort) );
262+
* console.println(Messages.ArduinoSerial_Continuing_to_use.replace(PORT,comPort
263+
* )); console.println(Messages.ArduinoSerial_Ending_reset); return comPort; }
264+
*
265+
* ToggleDTR(serialPort, 100);
266+
*
267+
* serialPort.dispose();
268+
* console.println(Messages.ArduinoSerial_Continuing_to_use.replace(PORT,
269+
* comPort)); console.println(Messages.ArduinoSerial_Ending_reset); return
270+
* comPort;
271+
*/
295272
}
296273
}

0 commit comments

Comments
 (0)