def dataReceived(self, data: bytes):
    '\n        Byte 1: command\n        Byte 2-5: length\n        Byte 6+: data\n        '
    self._buffer += data
    if (len(self._buffer) > 5):
        command = chr(self._buffer[0])
        length = int.from_bytes(self._buffer[1:5], byteorder='big')
        if (len(self._buffer) >= (length + 5)):
            data = self._buffer[5:(5 + length)]
            self._buffer = self._buffer[(5 + length):]
            if (command == 'F'):
                self.formatReceived(data)
            elif (command == 'I'):
                self.imageReceived(data)
Byte 1: command
Byte 2-5: length
Byte 6+: data
def dataReceived(self, data: bytes):
    '\n        Byte 1: command\n        Byte 2-5: length\n        Byte 6+: data\n        '
    self._buffer += data
    if (len(self._buffer) > 5):
        command = chr(self._buffer[0])
        length = int.from_bytes(self._buffer[1:5], byteorder='big')
        if (len(self._buffer) >= (length + 5)):
            data = self._buffer[5:(5 + length)]
            self._buffer = self._buffer[(5 + length):]
            if (command == 'F'):
                self.formatReceived(data)
            elif (command == 'I'):
                self.imageReceived(data)