@Override public List<String> getPortNames() { return Arrays.asList(SerialPortList.getPortNames()); }
/** * @return A HashSet containing the identifier for all serial ports */ public static HashSet<String> getSerialPorts() { final HashSet<String> ports = new HashSet<String>(); for (final String s : SerialPortList.getPortNames()) { ports.add(s); } return ports; } }
/** * @return A HashSet containing the identifier for all serial ports */ public static HashSet<String> getSerialPorts() { final HashSet<String> ports = new HashSet<String>(); for (final String s : SerialPortList.getPortNames()) { ports.add(s); } return ports; } }
/** * find all available serial ports * * @return a list of port names */ public String[] listConnections() { 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")); } return portsDetected; }
@SuppressWarnings("unchecked") private static String requestPort() { JComboBox<String> portNameSelector = new JComboBox<>(); portNameSelector.setModel(new DefaultComboBoxModel<String>()); String[] portNames; if (SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X) { // for MAC OS default pattern of jssc library is too restrictive portNames = SerialPortList.getPortNames("/dev/", Pattern.compile("tty\\..*")); } else { portNames = SerialPortList.getPortNames(); } for (String portName : portNames) { portNameSelector.addItem(portName); } if (portNameSelector.getItemCount() == 0) { JOptionPane.showMessageDialog(null, "Cannot find any serial port", "Error", JOptionPane.ERROR_MESSAGE); System.exit(1); } JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); panel.add(new JLabel("Port ")); panel.add(portNameSelector); if (JOptionPane.showConfirmDialog(null, panel, "Select the port", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { return portNameSelector.getSelectedItem().toString(); } else { System.exit(0); } return ""; }
@SuppressWarnings("unchecked") private static String requestPort() { JComboBox<String> portNameSelector = new JComboBox<>(); portNameSelector.setModel(new DefaultComboBoxModel<String>()); String[] portNames; if (SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X) { // for MAC OS default pattern of jssc library is too restrictive portNames = SerialPortList.getPortNames("/dev/", Pattern.compile("tty\\..*")); } else { portNames = SerialPortList.getPortNames(); } for (String portName : portNames) { portNameSelector.addItem(portName); } if (portNameSelector.getItemCount() == 0) { JOptionPane.showMessageDialog(null, "Cannot find any serial port", "Error", JOptionPane.ERROR_MESSAGE); System.exit(1); } JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); panel.add(new JLabel("Port ")); panel.add(portNameSelector); if (JOptionPane.showConfirmDialog(null, panel, "Select the port", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { return portNameSelector.getSelectedItem().toString(); } else { System.exit(0); } return ""; }
@SuppressWarnings("unchecked") private static String requestPort() { JComboBox<String> portNameSelector = new JComboBox<>(); portNameSelector.setModel(new DefaultComboBoxModel<String>()); String[] portNames; if (SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X) { // for MAC OS default pattern of jssc library is too restrictive portNames = SerialPortList.getPortNames("/dev/", Pattern.compile("tty\\..*")); } else { portNames = SerialPortList.getPortNames(); } for (String portName : portNames) { portNameSelector.addItem(portName); } if (portNameSelector.getItemCount() == 0) { JOptionPane.showMessageDialog(null, "Cannot find any serial port", "Error", JOptionPane.ERROR_MESSAGE); System.exit(1); } JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); panel.add(new JLabel("Port ")); panel.add(portNameSelector); if (JOptionPane.showConfirmDialog(null, panel, "Select the port", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { return portNameSelector.getSelectedItem().toString(); } else { System.exit(0); } return ""; }
@SuppressWarnings("unchecked") private static String requestPort() { JComboBox<String> portNameSelector = new JComboBox<>(); portNameSelector.setModel(new DefaultComboBoxModel<String>()); String[] portNames; if (SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X) { // for MAC OS default pattern of jssc library is too restrictive portNames = SerialPortList.getPortNames("/dev/", Pattern.compile("tty\\..*")); } else { portNames = SerialPortList.getPortNames(); } for (String portName : portNames) { portNameSelector.addItem(portName); } if (portNameSelector.getItemCount() == 0) { JOptionPane.showMessageDialog(null, "Cannot find any serial port", "Error", JOptionPane.ERROR_MESSAGE); System.exit(1); } JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); panel.add(new JLabel("Port ")); panel.add(portNameSelector); if (JOptionPane.showConfirmDialog(null, panel, "Select the port", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { return portNameSelector.getSelectedItem().toString(); } else { System.exit(0); } return ""; }
portNames = SerialPortList.getPortNames( Common.envProps.getString("serial.port.linux.path", "/dev/"), Pattern.compile(Common.envProps.getString("serial.port.linux.regex", break; case SerialNativeInterface.OS_MAC_OS_X: portNames = SerialPortList.getPortNames( Common.envProps.getString("serial.port.osx.path", "/dev/"), Pattern.compile(Common.envProps.getString("serial.port.osx.regex", break; case SerialNativeInterface.OS_WINDOWS: portNames = SerialPortList.getPortNames( Common.envProps.getString("serial.port.windows.path", ""), Pattern.compile( Common.envProps.getString("serial.port.windows.regex", ""))); default: portNames = SerialPortList.getPortNames(); break;
@Override public void connect() { String[] portNames = SerialPortList.getPortNames(); _logger.debug("Number of serial port available:{}", portNames.length); for (int portNo = 0; portNo < portNames.length; portNo++) {
@Override public void connect() { String[] portNames = SerialPortList.getPortNames(); _logger.debug("Number of serial port available:{}", portNames.length); for (int portNo = 0; portNo < portNames.length; portNo++) {