void runWrite() {
        Log.i(TAG, "runWrite running ...");
        try {
            setThreadPriority();
            mStartuplatch.countDown();
            do {
                stepWrite();
            } while (isStillRunning());
            Log.i(TAG, "runWrite: Stopping mState=" + getState());
        } catch (Throwable e) {
            if (Thread.currentThread().isInterrupted()) {
                Log.w(TAG, "runWrite: interrupted");
            } else if(mSerialPort.isOpen()) {
                Log.w(TAG, "runWrite ending due to exception: " + e.getMessage(), e);
            } else {
                Log.i(TAG, "runWrite: Socket closed");
            }
            notifyErrorListener(e);
        } finally {
            if (!mState.compareAndSet(State.RUNNING, State.STOPPING)) {
                if (mState.compareAndSet(State.STOPPING, State.STOPPED)) {
                    Log.i(TAG, "runWrite: Stopped mState=" + getState());
                }
            }
        }
    }
Continuously services the write buffers until {@link #stop()} is called, or until a driver exception is
raised.
usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/util/SerialInputOutputManager.java