# Path: tools/pyserial/serialutil.py
#     class memoryview(object):   # pylint: disable=redefined-builtin,invalid-name
# class SerialException(IOError):
# class SerialTimeoutException(SerialException):
# class Timeout(object):
# class SerialBase(io.RawIOBase):
# def iterbytes(b):
# def to_bytes(seq):
#     def __init__(self, duration):
#     def expired(self):
#     def time_left(self):
#     def restart(self, duration):
#     def __init__(self,
#                  port=None,
#                  baudrate=9600,
#                  bytesize=EIGHTBITS,
#                  parity=PARITY_NONE,
#                  stopbits=STOPBITS_ONE,
#                  timeout=None,
#                  xonxoff=False,
#                  rtscts=False,
#                  write_timeout=None,
#                  dsrdtr=False,
#                  inter_byte_timeout=None,
#                  exclusive=None,
#                  **kwargs):
#     def port(self):
#     def port(self, port):
#     def baudrate(self):
#     def baudrate(self, baudrate):
#     def bytesize(self):
#     def bytesize(self, bytesize):
#     def exclusive(self):
#     def exclusive(self, exclusive):
#     def parity(self):
#     def parity(self, parity):
#     def stopbits(self):
#     def stopbits(self, stopbits):
#     def timeout(self):
#     def timeout(self, timeout):
#     def write_timeout(self):
#     def write_timeout(self, timeout):
#     def inter_byte_timeout(self):
#     def inter_byte_timeout(self, ic_timeout):
#     def xonxoff(self):
#     def xonxoff(self, xonxoff):
#     def rtscts(self):
#     def rtscts(self, rtscts):
#     def dsrdtr(self):
#     def dsrdtr(self, dsrdtr=None):
#     def rts(self):
#     def rts(self, value):
#     def dtr(self):
#     def dtr(self, value):
#     def break_condition(self):
#     def break_condition(self, value):
#     def rs485_mode(self):
#     def rs485_mode(self, rs485_settings):
#     def get_settings(self):
#     def apply_settings(self, d):
#     def __repr__(self):
#     def readable(self):
#     def writable(self):
#     def seekable(self):
#     def readinto(self, b):
#     def __enter__(self):
#     def __exit__(self, *args, **kwargs):
#     def send_break(self, duration=0.25):
#     def flushInput(self):
#     def flushOutput(self):
#     def inWaiting(self):
#     def sendBreak(self, duration=0.25):
#     def setRTS(self, value=1):
#     def setDTR(self, value=1):
#     def getCTS(self):
#     def getDSR(self):
#     def getRI(self):
#     def getCD(self):
#     def setPort(self, port):
#     def writeTimeout(self):
#     def writeTimeout(self, timeout):
#     def interCharTimeout(self):
#     def interCharTimeout(self, interCharTimeout):
#     def getSettingsDict(self):
#     def applySettingsDict(self, d):
#     def isOpen(self):
#     def read_all(self):
#     def read_until(self, terminator=LF, size=None):
#     def iread_until(self, *args, **kwargs):
# XON = to_bytes([17])
# XOFF = to_bytes([19])
# CR = to_bytes([13])
# LF = to_bytes([10])
# PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE = 'N', 'E', 'O', 'M', 'S'
# STOPBITS_ONE, STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO = (1, 1.5, 2)
# FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS = (5, 6, 7, 8)
# PARITY_NAMES = {
#     PARITY_NONE: 'None',
#     PARITY_EVEN: 'Even',
#     PARITY_ODD: 'Odd',
#     PARITY_MARK: 'Mark',
#     PARITY_SPACE: 'Space',
# }
#         TIME = time.monotonic
#         TIME = time.time
#     BAUDRATES = (50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
#                  9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000,
#                  576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000,
#                  3000000, 3500000, 4000000)
#     BYTESIZES = (FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS)
#     PARITIES = (PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE)
#     STOPBITS = (STOPBITS_ONE, STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO)
#     _SAVED_SETTINGS = ('baudrate', 'bytesize', 'parity', 'stopbits', 'xonxoff',
#                        'dsrdtr', 'rtscts', 'timeout', 'write_timeout',
#                        'inter_byte_timeout')


import errno
import fcntl
import os
import select
import struct
import sys
import termios
    import array
    import array
        import warnings
from .serialutil import *
from .serialutil import SerialBase, SerialException, to_bytes, \
    portNotOpenError, writeTimeoutError, Timeout
        WARNING: this function is not portable to different platforms!
        """
        if not self.is_open:
            raise portNotOpenError
        if enable:
            termios.tcflow(self.fd, termios.TCOON)
        else:
            termios.tcflow(self.fd, termios.TCOOFF)

    def nonblocking(self):
        """DEPRECATED - has no use"""
        warnings.warn("nonblocking() has no effect, already nonblocking", DeprecationWarning)


class PosixPollSerial(Serial):
    """\
    Poll based read implementation. Not all systems support poll properly.
    However this one has better handling of errors, such as a device
    disconnecting while it's in use (e.g. USB-serial unplugged).
    """

    def read(self, size=1):
        """\
        Read size bytes from the serial port. If a timeout is set it may
        return less characters as requested. With no timeout it will block
        until the requested number of bytes is read.
        """
        if not self.is_open:
            raise portNotOpenError
        read = bytearray()

# Path: tools/pyserial/serialutil.py
#     class memoryview(object):   # pylint: disable=redefined-builtin,invalid-name
# class SerialException(IOError):
# class SerialTimeoutException(SerialException):
# class Timeout(object):
# class SerialBase(io.RawIOBase):
# def iterbytes(b):
# def to_bytes(seq):
#     def __init__(self, duration):
#     def expired(self):
#     def time_left(self):
#     def restart(self, duration):
#     def __init__(self,
#                  port=None,
#                  baudrate=9600,
#                  bytesize=EIGHTBITS,
#                  parity=PARITY_NONE,
#                  stopbits=STOPBITS_ONE,
#                  timeout=None,
#                  xonxoff=False,
#                  rtscts=False,
#                  write_timeout=None,
#                  dsrdtr=False,
#                  inter_byte_timeout=None,
#                  exclusive=None,
#                  **kwargs):
#     def port(self):
#     def port(self, port):
#     def baudrate(self):
#     def baudrate(self, baudrate):
#     def bytesize(self):
#     def bytesize(self, bytesize):
#     def exclusive(self):
#     def exclusive(self, exclusive):
#     def parity(self):
#     def parity(self, parity):
#     def stopbits(self):
#     def stopbits(self, stopbits):
#     def timeout(self):
#     def timeout(self, timeout):
#     def write_timeout(self):
#     def write_timeout(self, timeout):
#     def inter_byte_timeout(self):
#     def inter_byte_timeout(self, ic_timeout):
#     def xonxoff(self):
#     def xonxoff(self, xonxoff):
#     def rtscts(self):
#     def rtscts(self, rtscts):
#     def dsrdtr(self):
#     def dsrdtr(self, dsrdtr=None):
#     def rts(self):
#     def rts(self, value):
#     def dtr(self):
#     def dtr(self, value):
#     def break_condition(self):
#     def break_condition(self, value):
#     def rs485_mode(self):
#     def rs485_mode(self, rs485_settings):
#     def get_settings(self):
#     def apply_settings(self, d):
#     def __repr__(self):
#     def readable(self):
#     def writable(self):
#     def seekable(self):
#     def readinto(self, b):
#     def __enter__(self):
#     def __exit__(self, *args, **kwargs):
#     def send_break(self, duration=0.25):
#     def flushInput(self):
#     def flushOutput(self):
#     def inWaiting(self):
#     def sendBreak(self, duration=0.25):
#     def setRTS(self, value=1):
#     def setDTR(self, value=1):
#     def getCTS(self):
#     def getDSR(self):
#     def getRI(self):
#     def getCD(self):
#     def setPort(self, port):
#     def writeTimeout(self):
#     def writeTimeout(self, timeout):
#     def interCharTimeout(self):
#     def interCharTimeout(self, interCharTimeout):
#     def getSettingsDict(self):
#     def applySettingsDict(self, d):
#     def isOpen(self):
#     def read_all(self):
#     def read_until(self, terminator=LF, size=None):
#     def iread_until(self, *args, **kwargs):
# XON = to_bytes([17])
# XOFF = to_bytes([19])
# CR = to_bytes([13])
# LF = to_bytes([10])
# PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE = 'N', 'E', 'O', 'M', 'S'
# STOPBITS_ONE, STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO = (1, 1.5, 2)
# FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS = (5, 6, 7, 8)
# PARITY_NAMES = {
#     PARITY_NONE: 'None',
#     PARITY_EVEN: 'Even',
#     PARITY_ODD: 'Odd',
#     PARITY_MARK: 'Mark',
#     PARITY_SPACE: 'Space',
# }
#         TIME = time.monotonic
#         TIME = time.time
#     BAUDRATES = (50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
#                  9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000,
#                  576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000,
#                  3000000, 3500000, 4000000)
#     BYTESIZES = (FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS)
#     PARITIES = (PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE)
#     STOPBITS = (STOPBITS_ONE, STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO)
#     _SAVED_SETTINGS = ('baudrate', 'bytesize', 'parity', 'stopbits', 'xonxoff',
#                        'dsrdtr', 'rtscts', 'timeout', 'write_timeout',
#                        'inter_byte_timeout')


# Path: tools/pyserial/serialposix.py
import errno
import fcntl
import os
import select
import struct
import sys
import termios
    import array
    import array
        import warnings
from .serialutil import *
from .serialutil import SerialBase, SerialException, to_bytes, \
    portNotOpenError, writeTimeoutError, Timeout

        WARNING: this function is not portable to different platforms!
        """
        if not self.is_open:
            raise portNotOpenError
        if enable:
            termios.tcflow(self.fd, termios.TCOON)
        else:
            termios.tcflow(self.fd, termios.TCOOFF)

    def nonblocking(self):
        """DEPRECATED - has no use"""
        warnings.warn("nonblocking() has no effect, already nonblocking", DeprecationWarning)


class PosixPollSerial(Serial):
    """\
    Poll based read implementation. Not all systems support poll properly.
    However this one has better handling of errors, such as a device
    disconnecting while it's in use (e.g. USB-serial unplugged).
    """

    def read(self, size=1):
        """\
        Read size bytes from the serial port. If a timeout is set it may
        return less characters as requested. With no timeout it will block
        until the requested number of bytes is read.
        """
        if not self.is_open:
            raise portNotOpenError
        read = bytearray()

        timeout = Timeout(self._timeout)