@Override
    public void openIF(boolean safeMode) throws RoombaIFException {
        serialPort = new SerialPort(portName);
        if (isOpened) {
            throw new RoombaIFException(RoombaIFException.TYPE_ALREADY_OPEN);
        }
        try {
            serialPort.openPort();
            serialPort.setParams(BAUDRATE, DATABITS, STOPBITS, PARITY);
            int mask = SerialPort.MASK_RXCHAR;
            serialPort.setEventsMask(mask);
            serialPort.addEventListener(new SerialPortReader());
            serialPort.writeByte(START_COMMAND); //passive mode
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
                //Don't do anything. Nothing sends this thread an interrupt.
            }
            if (safeMode) {
                serialPort.writeByte(SAFE_COMMAND); //safe mode 
            } else {
                serialPort.writeByte(FULL_COMMAND); //full mode 
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
                //Don't do anything. Nothing sends this thred an interrupt.
            }
            byte[] c = new byte[sensorPacketsRequested.length + 2];
            c[0] = STREAM_COMMAND;
            c[1] = (byte) sensorPacketsRequested.length;
            for (int i = 0; i < sensorPacketsRequested.length; i++) {
                c[i + 2] = sensorPacketsRequested[i].id();
            }
            serialPort.writeBytes(c);
        } catch (SerialPortException ex) {
            try {
                if (serialPort.isOpened()) {
                    serialPort.closePort();
                }
            } catch (SerialPortException ex2) {
                //Don't do anything. We are already going to throw an exception.
            }
            throw new RoombaIFException(RoombaIFException.TYPE_SERIAL + ": "
                    + ex.getMessage());
        }
        watchdogTimer = new Thread(new WatchdogTimer());
        watchdogTimer.start();
        isOpened = true;
    }