forked from LupusNobilis/java-org.hwo
nsp update (OSX), added getPortNamesOSX()
parent
bf54a3f4b7
commit
bd9472b39b
Binary file not shown.
Binary file not shown.
|
@ -297,6 +297,8 @@ public class NewSerialPort {
|
||||||
return getPortNamesLIN();
|
return getPortNamesLIN();
|
||||||
case WINDOWS:
|
case WINDOWS:
|
||||||
return getPortNamesWIN();
|
return getPortNamesWIN();
|
||||||
|
case OSX:
|
||||||
|
return getPortNamesOSX();
|
||||||
default:
|
default:
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
@ -339,6 +341,26 @@ public class NewSerialPort {
|
||||||
|
|
||||||
return portNames.toArray(new String[0]);
|
return portNames.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
static public String[] getPortNamesOSX()
|
||||||
|
{
|
||||||
|
ArrayList<String> portNames = new ArrayList<String>();
|
||||||
|
|
||||||
|
File devDir = new File("/dev");
|
||||||
|
File[] list = devDir.listFiles(new FilenameFilter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(File arg0, String arg1) {
|
||||||
|
if (arg1.startsWith("tty.") || arg1.startsWith("ttyS"))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (File file:list)
|
||||||
|
portNames.add("/dev/" + file.getName());
|
||||||
|
|
||||||
|
return portNames.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue