Skip to content

Adding explicit instructions about /var/lock #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import it.baeyens.arduino.common.ArduinoConst;
import it.baeyens.arduino.common.Common;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -190,8 +191,22 @@ public void connect() {
}
}
} catch (PortInUseException e) {
Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Serial port " + PortName
+ " already in use. Try quiting any programs that may be using it", e));
String OS = System.getProperty("os.name", "generic").toLowerCase();
boolean isMac, haveVarLock = false;
isMac = ((OS.indexOf("mac") >= 0) || (OS.indexOf("darwin") >= 0));
if (isMac) {
File varLock = new File("/var/lock");
haveVarLock = varLock.exists() && varLock.canWrite();
}
if (isMac && !haveVarLock) {
Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Serial port " + PortName
+ " is not accessible or already in use: try quitting all other programs that may be using it."
+ "\n\nIf that doesn't fix it, please run the following command:"
+ "\n\nsudo mkdir -p /var/lock && sudo chmod 777 /var/lock\n"));
} else {
Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Serial port " + PortName
+ " already in use. Try to quit all other programs that may be using it.", e));
}
return;
} catch (Exception e) {
Common.log(new Status(IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Error opening serial port " + PortName, e));
Expand Down Expand Up @@ -232,7 +247,9 @@ public void disconnect() {
}

public void dispose() {
notifyConsumersOfEvent("Disconnect of port " + port.getName() + " executed");
if (port != null)
notifyConsumersOfEvent("Disconnect of port " + port.getName() + " executed");

disconnect();

if (fServiceRegistration != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ public static String wait_for_com_Port_to_appear(Vector<String> OriginalPorts, S

// 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
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 {
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 > 0) {
try {
Thread.sleep(delayMs);
} catch (InterruptedException e) {// Jaba is not going to write this
// code
}
}
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;
Expand Down