public static USBConnection getConnection() throws PortInUseException,
		UnsupportedCommOperationException, IOException {
		@SuppressWarnings("unchecked")
		Enumeration<CommPortIdentifier> ports = CommPortIdentifier.getPortIdentifiers();

		LOG.debug("Starting to probe ports.");

		while (ports.hasMoreElements()) {
			CommPortIdentifier portId = ports.nextElement();

			LOG.info("Probing port: " + portId.getName());
			if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
				LOG.debug("Opening serial port " + portId.getName() + " for probing.");
				USBConnection u = new USBConnection(portId);
				u.connect();
				if (u.isActive()) {
					LOG.info("Probe successful for port: " + portId.getName());
					u.disconnect();
					return u;
				}
				u.disconnect();
			}
		}

		// did not probe successfully on any port :(
		return null;
	}