Ejemplo n.º 1
0
    def __init__(self, eieio_header, data=None, offset=0):
        EIEIODataMessage.__init__(self, eieio_header, data, offset)

        if eieio_header.eieio_type.payload_bytes == 0:
            raise SpinnmanInvalidParameterException(
                "eieio_header", eieio_header,
                "This message should have a payload, but the header indicates"
                " that it doesn't")
    def __init__(self, eieio_header, data=None, offset=0):
        EIEIODataMessage.__init__(self, eieio_header, data, offset)

        if eieio_header.eieio_type.payload_bytes == 0:
            raise SpinnmanInvalidParameterException(
                "eieio_header", eieio_header,
                "This message should have a payload, but the header indicates"
                " that it doesn't")
    def add_key(self, key):
        """ Add a key to the packet

        :param key: The key to add
        :type key: int
        :raise SpinnmanInvalidParameterException: If the key is too\
                    big for the format
        """
        if key > self._eieio_header.eieio_type.max_value:
            raise SpinnmanInvalidParameterException(
                "key", key, "Larger than the maximum allowed of {}".format(
                    self._eieio_header.eieio_type.max_value))
        EIEIODataMessage.add_element(self, EIEIOKeyDataElement(key))
    def add_key(self, key):
        """ Add a key to the packet

        :param key: The key to add
        :type key: int
        :raise SpinnmanInvalidParameterException: If the key is too\
                    big for the format
        """
        if key > self._eieio_header.eieio_type.max_value:
            raise SpinnmanInvalidParameterException(
                "key", key,
                "Larger than the maximum allowed of {}".format(
                    self._eieio_header.eieio_type.max_value))
        EIEIODataMessage.add_element(self, EIEIOKeyDataElement(key))
def read_eieio_data_message(data, offset):
    """ Reads the content of an EIEIO data message and returns an object\
        identifying the data which was contained in the packet

    :param data: data received from the network
    :type data: bytestring
    :param offset: offset at which the parsing operation should start
    :type offset: int
    :return: an object which inherits from EIEIODataMessage which contains\
            parsed data received from the network
    :rtype:\
            :py:class:`spinnman.messages.eieio.data_messages.eieio_data_message.EIEIODataMessage`
    """
    eieio_header = EIEIODataHeader.from_bytestring(data, offset)
    offset += eieio_header.size
    eieio_type = eieio_header.eieio_type
    prefix = eieio_header.prefix
    payload_base = eieio_header.payload_base
    prefix_type = eieio_header.prefix_type
    is_time = eieio_header.is_time
    if eieio_type == EIEIOType.KEY_16_BIT:
        return _read_16_bit_message(prefix, payload_base, prefix_type, is_time,
                                    data, offset, eieio_header)
    elif eieio_type == EIEIOType.KEY_PAYLOAD_16_BIT:
        return _read_16_bit_payload_message(prefix, payload_base, prefix_type,
                                            is_time, data, offset,
                                            eieio_header)
    elif eieio_type == EIEIOType.KEY_32_BIT:
        return _read_32_bit_message(prefix, payload_base, prefix_type, is_time,
                                    data, offset, eieio_header)
    elif eieio_type == EIEIOType.KEY_PAYLOAD_32_BIT:
        return _read_32_bit_payload_message(prefix, payload_base, prefix_type,
                                            is_time, data, offset,
                                            eieio_header)
    return EIEIODataMessage(eieio_header, data, offset)
    def add_key_and_payload(self, key, payload):
        """ Adds a key and payload to the packet

        :param key: The key to add
        :type key: int
        :param payload: The payload to add
        :type payload: int
        :raise SpinnmanInvalidParameterException: If the key or payload is too\
                    big for the format
        """
        if key > self._eieio_header.eieio_type.max_value:
            raise SpinnmanInvalidParameterException(
                "key", key,
                "Larger than the maximum allowed of {}".format(
                    self._eieio_header.eieio_type.max_value))
        if payload > self._eieio_header.eieio_type.max_value:
            raise SpinnmanInvalidParameterException(
                "payload", payload,
                "Larger than the maximum allowed of {}".format(
                    self._eieio_header.eieio_type.max_value))
        EIEIODataMessage.add_element(
            self, EIEIOKeyPayloadDataElement(key, payload,
                                             self._eieio_header.is_time))
Ejemplo n.º 7
0
    def add_key_and_payload(self, key, payload):
        """ Adds a key and payload to the packet

        :param key: The key to add
        :type key: int
        :param payload: The payload to add
        :type payload: int
        :raise SpinnmanInvalidParameterException: If the key or payload is too\
                    big for the format
        """
        if key > self._eieio_header.eieio_type.max_value:
            raise SpinnmanInvalidParameterException(
                "key", key, "Larger than the maximum allowed of {}".format(
                    self._eieio_header.eieio_type.max_value))
        if payload > self._eieio_header.eieio_type.max_value:
            raise SpinnmanInvalidParameterException(
                "payload", payload,
                "Larger than the maximum allowed of {}".format(
                    self._eieio_header.eieio_type.max_value))
        EIEIODataMessage.add_element(
            self,
            EIEIOKeyPayloadDataElement(key, payload,
                                       self._eieio_header.is_time))
 def get_min_packet_length():
     return EIEIODataMessage.min_packet_length(
         EIEIOType.KEY_PAYLOAD_32_BIT, is_prefix=True)
 def get_min_packet_length():
     return EIEIODataMessage.min_packet_length(EIEIOType.KEY_16_BIT,
                                               is_payload_base=True,
                                               is_prefix=True)
Ejemplo n.º 10
0
 def get_min_packet_length():
     return EIEIODataMessage.min_packet_length(EIEIOType.KEY_32_BIT)
Ejemplo n.º 11
0
 def get_min_packet_length():
     return EIEIODataMessage.min_packet_length(EIEIOType.KEY_PAYLOAD_16_BIT,
                                               is_prefix=True)
 def get_min_packet_length():
     return EIEIODataMessage.min_packet_length(
         EIEIOType.KEY_16_BIT, is_payload_base=True)
 def get_min_packet_length():
     return EIEIODataMessage.min_packet_length(EIEIOType.KEY_PAYLOAD_32_BIT)
Ejemplo n.º 14
0
 def get_min_packet_length():
     return EIEIODataMessage.min_packet_length(EIEIOType.KEY_PAYLOAD_32_BIT,
                                               is_payload_base=True)
 def get_min_packet_length():
     return EIEIODataMessage.min_packet_length(
         EIEIOType.KEY_PAYLOAD_16_BIT)
 def get_min_packet_length():
     return EIEIODataMessage.min_packet_length(EIEIOType.KEY_16_BIT)