# Buggy code
def processIncomingPacket(self, data, callback, unit, **kwargs):
    """
        The new packet processing pattern

        This takes in a new request packet, adds it to the current
        packet stream, and performs framing on it. That is, checks
        for complete messages, and once found, will process all that
        exist.  This handles the case when we read N + 1 or 1 // N
        messages at a time instead of 1.

        The processed and decoded messages are pushed to the callback
        function to process and send.

        :param data: The new packet data
        :param callback: The function to send results to
        :param unit: Process if unit id matches, ignore otherwise (could be a \
        list of unit ids (server) or single unit id(client/server))
        :param single: True or False (If True, ignore unit address validation)
        """
    if not isinstance(unit, (list, tuple)):
        unit = [unit]
    single = kwargs.get("single", False)
    self.addToFrame(data)
    while self.isFrameReady():
        if self.checkFrame():
            if self._validate_unit_id(unit, single):
                frame = self.getFrame()
                result = self.decoder.decode(frame)
                if result is None:
                    raise ModbusIOException("Unable to decode response")
                self.populateResult(result)
                self.advanceFrame()
                callback(result)  # defer this
            else:
                _logger.error(
                    "Not a valid unit id - {}, ignoring!!".format(self._header["uid"])
                )
                self.resetFrame()
        else:
            break


# Traceback (AttributeError)
client = ModbusSerialClient(port='notexist', method='rtu')
client.connect()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "lib/python3.6/site-packages/pymodbus/client/sync.py", line 476, in connect
self.socket.interCharTimeout = self.inter_char_timeout
AttributeError: 'NoneType' object has no attribute 'interCharTimeout'

# Fixed code
def processIncomingPacket(self, data, callback, unit, **kwargs):
    """
    The new packet processing pattern

    This takes in a new request packet, adds it to the current
    packet stream, and performs framing on it. That is, checks
    for complete messages, and once found, will process all that
    exist.  This handles the case when we read N + 1 or 1 // N
    messages at a time instead of 1.

    The processed and decoded messages are pushed to the callback
    function to process and send.

    :param data: The new packet data
    :param callback: The function to send results to
    :param unit: Process if unit id matches, ignore otherwise (could be a
           list of unit ids (server) or single unit id(client/server))
    :param single: True or False (If True, ignore unit address validation)

    """
    if not isinstance(unit, (list, tuple)):
        unit = [unit]
    single = kwargs.get("single", False)
    self.addToFrame(data)
    while self.isFrameReady():
        if self.checkFrame():
            if self._validate_unit_id(unit, single):
                frame = self.getFrame()
                result = self.decoder.decode(frame)
                if result is None:
                    raise ModbusIOException("Unable to decode response")
                self.populateResult(result)
                self.advanceFrame()
                callback(result)  # defer this
            else:
                _logger.error(
                    "Not a valid unit id - {}, ignoring!!".format(self._header["uid"])
                )
                self.resetFrame()
        else:
            break