<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def rawDataReceived(self, data):
 """ Called when raw data is received. Fill the raw buffer C{_rawBuffer} until we have received at least C{_expectedLength} bytes. Call C{datagramReceived} with the received byte string of the expected size. Then switch back to line mode with the remainder of the buffer. """

        self._rawBuffer.append(data)
        self._rawBufferLength += len(data)

        if self._rawBufferLength >= self._expectedLength:
            receivedData = ''.join(self._rawBuffer)
            expectedData = receivedData[:self._expectedLength]
            extraData = receivedData[self._expectedLength:]

            self._rawBuffer = None
            self._rawBufferLength = None
            self._expectedLength = None

            self.datagramReceived(expectedData)
            self.setLineMode(extraData)