public void serialEvent(SerialPortEvent e) {
	 	// Create a StringBuffer and int to receive input data.
		StringBuffer inputBuffer = new StringBuffer();
		int newData = 0;
	
		// Determine type of event.
		switch (e.getEventType()) {
		    // Read data until -1 is returned. If \r is received substitute
		    // \n for correct newline handling.
		    case SerialPortEvent.DATA_AVAILABLE:
			    while (newData != -1) {
			    	try {
			    	    newData = is.read();
					    if (newData == -1) {
					    	break;
					    }
					    if ('\r' == (char)newData) {
					    	inputBuffer.append('\n');
					    } else {
					    	inputBuffer.append((char)newData);
					    }
			    	} catch (IOException ex) {
			    	    System.err.println(ex);
			    	    return;
			      	}
	   		    }
	
				// Append received data to messageAreaIn.
			   	this.gui.printReceive(new String(inputBuffer));
			  	this.controller.getSerial().getParser().process(new String(inputBuffer));
			break;
	
		    // If break event append BREAK RECEIVED message.
		    case SerialPortEvent.BI:
		    this.gui.printReceive("\n--- BREAK RECEIVED ---\n");
		}
    }