Permalink
Browse files

Fixing timing issue with resetting Esplora

- it appears that at least on a Mac some assumptions about Esplora are slightly different:
  * there are two usb serial ports, not one (cu.xxx and tty.xxx)
  * after sending 1200 baud to the COM port it takes no time for ports to get reset, so our checks
    are not registering any disappearing ports in this case even at 10ms interval. Worked around
    by switching this into a WARNING and allowing to continue after 2 seconds of trying, which leaves
    another 6 seconds on Esplore, in the case when reset actually worked (for me 100% of the time).
  • Loading branch information...
kigster committed Jul 9, 2014
1 parent 0f7e075 commit fd0f6de12ebf41a0ba484d3007bfed77c67380ec
Showing with 14 additions and 9 deletions.
  1. +14 −9 it.baeyens.arduino.core/src/it/baeyens/arduino/communication/ArduinoSerial.java
@@ -58,17 +58,22 @@ public static String wait_for_com_Port_to_appear(Vector<String> OriginalPorts, S
Vector<String> NewPorts;
Vector<String> OriginalPortsCopy;


// wait for port to disappear
int NumTries = 0;
int MaxTries = 200; // wait for 2 seconds, leaves us 6secs in case we are not seeing disappearing ports but reset worked
int delayMs = 10; // on faster computers Esplora reconnects *extremely* quickly and we can't catch this
do {
try {
Thread.sleep(100);
} catch (InterruptedException e) {// Jaba is not going to write this
// code
}
if (NumTries > 0) {
try {
Thread.sleep(delayMs);
} catch (InterruptedException e) {// Jaba is not going to write this
// code
}
}
OriginalPortsCopy = new Vector<String>(OriginalPorts);
if (NumTries++ > 70) {
Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Leonardo upload port is not disappearing after reset"));
if (NumTries++ > MaxTries) {
Common.log(new Status(IStatus.WARNING, ArduinoConst.CORE_PLUGIN_ID, "Leonardo upload port is not disappearing after reset and " + NumTries + " checks"));
return defaultComPort;
}
NewPorts = Serial.list();
@@ -81,7 +86,7 @@ public static String wait_for_com_Port_to_appear(Vector<String> OriginalPorts, S

NumTries = 0;
do {
if (NumTries++ > 70) {
if (NumTries++ > MaxTries) {
Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Leonardo upload port is not appearing after reset"));
return defaultComPort;
}
@@ -90,7 +95,7 @@ public static String wait_for_com_Port_to_appear(Vector<String> OriginalPorts, S
NewPorts.remove(OriginalPorts.get(i));
}
try {
Thread.sleep(100);
Thread.sleep(delayMs);
} catch (InterruptedException e) {// Jaba is not going to write this
// code
}

0 comments on commit fd0f6de

Please sign in to comment.