private void connect(String portName) throws IOException {
//        portName = "/dev/ttyUSB0";
        log.debug("PortName: {}", portName);
        try {
            /*  Obtain a CommPortIdentifier object for the port you want to open */
            CommPortIdentifier portId =
                    CommPortIdentifier.getPortIdentifier(portName);

            /*  Get the port's ownership */
            serialPort = (SerialPort) portId.open("Demo application", 5000);

            /*  Set the parameters of the connection. */
            setSerialPortParameters();

            /* Open the input and output streams for the connection.
             If they won't open, close the port before throwing an
             exception. */
            outputStream = serialPort.getOutputStream();
            inputStream = serialPort.getInputStream();
            serialPort.addEventListener(new SerialPortEventListener() {
                @Override
                public void serialEvent(SerialPortEvent serialPortEvent) {
                    switch (serialPortEvent.getEventType()) {
                        case SerialPortEvent.DATA_AVAILABLE:
                            byte[] readBuffer = new byte[400];
                            try {
                                Thread.sleep(600);
                                int availableBytes = inputStream.available();
                                if (availableBytes > 0) {
                                    /* Read the serial port */
                                    inputStream.read(readBuffer, 0, availableBytes);
                                    byte[] readCopy = Arrays.copyOfRange(readBuffer,0, availableBytes);

                                    /* Print it out */
                                    log.debug("Received : {} coverted to {}", readCopy, new String(readCopy));
                                    if(serialListener !=null){
                                        serialListener.onMessage(readCopy);
                                    }
                                }
                            } catch (IOException e) {
                            } catch (InterruptedException e) {
                            }
                    }
                }
            });
            serialPort.notifyOnDataAvailable(true);
        } catch (NoSuchPortException e) {
            log.error("Exception ", e);
            throw new IOException(e.getMessage());
        } catch (PortInUseException e) {
            log.error("Exception ", e);
            throw new IOException(e.getMessage());
        } catch (TooManyListenersException e) {
            log.error("Exception ", e);
            throw new IOException(e.getMessage());
        } catch (IOException e) {
            log.error("Exception ", e);
            serialPort.close();
            throw e;
        }
    }