SerialPortList.getPortNames
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using jssc.SerialPortList.getPortNames (Showing top 11 results out of 315)

origin: winder/Universal-G-Code-Sender

@Override
public List<String> getPortNames() {
  return Arrays.asList(SerialPortList.getPortNames());
}
origin: openimaj/openimaj

  /**
   * @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;
  }
}
origin: org.openimaj.hardware/serial-driver

  /**
   * @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;
  }
}
origin: MarginallyClever/Makelangelo-software

/**
 * 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;
}
origin: kurbatov/firmata4j

@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 "";
}
origin: com.github.kurbatov/firmata4j

@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 "";
}
origin: com.github.kurbatov/firmata4j

@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 "";
}
origin: kurbatov/firmata4j

@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 "";
}
origin: infiniteautomation/ma-core-public

  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;
origin: org.mycontroller.standalone/mycontroller-core

@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++) {
origin: mycontroller-org/mycontroller

@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++) {
jsscSerialPortListgetPortNames

Popular methods of SerialPortList

    Popular in Java

    • Parsing JSON documents to java classes using gson
    • findViewById (Activity)
    • runOnUiThread (Activity)
    • getSupportFragmentManager (FragmentActivity)
      Return the FragmentManager for interacting with fragments associated with this activity.
    • Thread (java.lang)
      A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
    • NumberFormat (java.text)
      The abstract base class for all number formats. This class provides the interface for formatting and
    • Collections (java.util)
      This class consists exclusively of static methods that operate on or return collections. It contains
    • LogFactory (org.apache.commons.logging)
      Factory for creating Log instances, with discovery and configuration features similar to that employ
    • IsNull (org.hamcrest.core)
      Is the value null?
    • Location (org.springframework.beans.factory.parsing)
      Class that models an arbitrary location in a Resource.Typically used to track the location of proble

    For IntelliJ IDEA,
    Android Studio or Eclipse

    • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
    • EnterpriseFAQAboutBlogContact Us
    • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
    Add Codota to your IDE (free)