nsp update (OSX), added getPortNamesOSX()

thobaben_serialize
haraldwolff 2016-09-09 00:58:48 +02:00
parent bf54a3f4b7
commit bd9472b39b
3 changed files with 22 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@ -297,6 +297,8 @@ public class NewSerialPort {
return getPortNamesLIN();
case WINDOWS:
return getPortNamesWIN();
case OSX:
return getPortNamesOSX();
default:
return new String[0];
}
@ -339,6 +341,26 @@ public class NewSerialPort {
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]);
}
}