Skip to content

Commit

Permalink
updated serial port detection to be linux friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed May 3, 2016
1 parent 4772925 commit 9de4693
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions java/src/com/marginallyclever/gcodesender/SerialConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,23 @@ public void SendCommand(String command) {
sendQueuedCommand();
}

// find all available serial ports for the settings->ports menu.
// Find all available serial ports for the settings->ports menu.
public void DetectSerialPorts() {
if(System.getProperty("os.name").equals("Mac OS X")){
portsDetected = SerialPortList.getPortNames("/dev/");
} else {
portsDetected = SerialPortList.getPortNames("COM");
}
String OS = System.getProperty("os.name").toLowerCase();

if (OS.indexOf("mac") >= 0) {
portsDetected = SerialPortList.getPortNames("/dev/");
//System.out.println("OS X");
} else if (OS.indexOf("win") >= 0) {
portsDetected = SerialPortList.getPortNames("COM");
//System.out.println("Windows");
} else if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0) {
portsDetected = SerialPortList.getPortNames("/dev/");
//System.out.println("Linux/Unix");
} else {
System.out.println("OS ERROR");
System.out.println("OS NAME=" + System.getProperty("os.name"));
}
}

public boolean PortExists(String portName) {
Expand Down

0 comments on commit 9de4693

Please sign in to comment.