def get_message(self):
        """Process the accumulated buffer and return the first message.

        If the buffer starts with FIX fields other than BeginString
        (8), these are discarded until the start of a message is
        found.

        If no BeginString (8) field is found, this function returns
        None.  Similarly, if (after a BeginString) no Checksum (10)
        field is found, the function returns None.

        Otherwise, it returns a simplefix.FixMessage instance
        initialised with the fields from the first complete message
        found in the buffer."""

        # Break buffer into tag=value pairs.
        start = 0
        point = 0
        in_tag = True
        tag = 0

        while point < len(self.buf):
            if in_tag and self.buf[point] == EQUALS_BYTE:
                tag_string = self.buf[start:point]
                point += 1

                tag = int(tag_string)
                if tag in self.raw_data_tags and self.raw_len > 0:
                    if self.raw_len > len(self.buf) - point:
                        break

                    value = self.buf[point:point + self.raw_len]
                    self.pairs.append((tag, value))
                    self.buf = self.buf[point + self.raw_len + 1:]
                    point = 0
                    self.raw_len = 0
                    start = point

                else:
                    in_tag = False
                    start = point

            elif self.buf[point] == SOH_BYTE:
                value = self.buf[start:point]
                self.pairs.append((tag, value))
                self.buf = self.buf[point + 1:]
                point = 0
                start = point
                in_tag = True

                if tag in self.raw_len_tags:
                    self.raw_len = int(value)

            point += 1

        if len(self.pairs) == 0:
            return None

        # Check first pair is FIX BeginString.
        while self.pairs and self.pairs[0][0] != 8:
            # Discard pairs until we find the beginning of a message.
            self.pairs.pop(0)

        if len(self.pairs) == 0:
            return None

        # Look for checksum.
        index = 0
        while index < len(self.pairs) and self.pairs[index][0] != 10:
            index += 1

        if index == len(self.pairs):
            return None

        # Found checksum, so we have a complete message.
        m = FixMessage()
        pairs = self.pairs[:index + 1]
        for tag, value in pairs:
            m.append_pair(tag, value)
        self.pairs = self.pairs[index + 1:]

        return m
Process the accumulated buffer and return the first message.

        If the buffer starts with FIX fields other than BeginString
        (8), these are discarded until the start of a message is
        found.

        If no BeginString (8) field is found, this function returns
        None.  Similarly, if (after a BeginString) no Checksum (10)
        field is found, the function returns None.

        Otherwise, it returns a simplefix.FixMessage instance
        initialised with the fields from the first complete message
        found in the buffer.