import collections


def parse_message(message, payload):
    """
    Parse a byte array and gives the data back in form of a dict.

    :param message: A MessageDefinitionObject
    :param payload: a bytes object of the message to read.
    :return: an ordered dictionary of parsed data.
    """
    result = collections.OrderedDict()
    if message.elements:
        for elem in message.elements:
            payload_chunk = payload[elem.start:elem.end]
            result[elem.name] = elem.func(payload_chunk)
            if elem.text_translate:
                result[elem.name+'_text'] = elem.text_translate.get(result[elem.name], 'unknown value')

    return result