@Override
    public void run() {

        // Loop until we receive client calls the stop thread method

        _isStopped.set(false);
        while (!_stopThread.get()) {

            try {

                // Just burn time in POLL_RATE increments while paused
                while (_isPaused.get()) {

                    sleep(RS232Configuration.INSTANCE.getPollrate());
                }

                if (_serialNumberRequested.get()) {

                    handleSerialNumberRequest();

                } else if (_resetRequested.get()) {

                    handleResetRequest();

                } else {

                    handleNormalLoop();
                }

                // If we made it this far, the loop has not stalled.
                _comOkay = true;

            } catch (SerialPortException ex) {
                logger.error(ex.getMessage());
                _comOkay = false;
            } catch (SerialPortTimeoutException ex1) {
                logger.error("SendBytes timed out. ({} ms)", APIConstants.COMM_TIMEOUT);
                _comOkay = false;
            }


            // Detect if there have been a number of sequential communication failures. Notify as needed.
            if (!_comOkay) {
                if (_failureCount++ >= RS232Configuration.INSTANCE.getPollRetryLimit()) {
                    fireChangeEvent(new ConnectionFailureEvent(this, _failureCount));
                }
            } else {
                _failureCount = 0;
            }


            // Wait for pollRate milliseconds before looping through again
            sleep(RS232Configuration.INSTANCE.getPollrate());
        }

        _isStopped.set(true);
    }