package de.lazyzero.NazeWiiConf.utils;

import gnu.io.CommPortIdentifier;

import java.util.Vector;

/**
 * @author moll
 * 
 */
public class PortScanner {



	/**
	 * @return List all serial ports
	 */
	public static Vector<String> listSerialPorts() {
		Vector<String> ports = new Vector<String>();

		java.util.Enumeration<CommPortIdentifier> portEnum = CommPortIdentifier
				.getPortIdentifiers();
		while (portEnum.hasMoreElements()) {
			CommPortIdentifier portIdentifier = portEnum.nextElement();
			if (portIdentifier.getPortType() == CommPortIdentifier.PORT_SERIAL) {
				if (System.getProperty("os.name").toLowerCase().contains("mac")) {
					if (portIdentifier.getName().contains("cu")) {
						ports.add(portIdentifier.getName());
					}
				} else {
					ports.add(portIdentifier.getName());
				}
			}
		}

		return ports;
	}

	
}
