public void initialize() {
		mPortId = null;
		@SuppressWarnings("rawtypes")
		Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
	
		//First, Find an instance of serial port as set in PORT_NAMES.
		while (portEnum.hasMoreElements()) {
			CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
			for (String portName : PORT_NAMES) {
				if (currPortId.getName().equals(portName)) {
					if (sPortsInUse.contains(currPortId)) {
						continue;
					}
					
					mPortId = currPortId;
					break;
				}
			}
		}
		if (mPortId == null) {
			System.out.println("Could not find COM port.");
			return;
		}
	
		try {
			// open serial port, and use class name for the appName.
			mSerialPort = (SerialPort) mPortId.open(this.getClass().getName(),
					TIME_OUT);
	
			// set port parameters
			mSerialPort.setSerialPortParams(DATA_RATE,
					SerialPort.DATABITS_8,
					SerialPort.STOPBITS_1,
					SerialPort.PARITY_NONE);
	
			// open the streams
			mInput = new BufferedReader(new InputStreamReader(mSerialPort.getInputStream()));
			mOutput = mSerialPort.getOutputStream();
			mPrintWriter = new PrintWriter(mOutput);
	
			// add event listeners
			mSerialPort.addEventListener(this);
			mSerialPort.notifyOnDataAvailable(true);
			
			// add port IDs to used list
			sPortsInUse.add(mPortId);
		} catch (Exception e) {
			System.err.println(e.toString());
		}
	}