def recv(self, data):
     message = read_eieio_data_message(data, 0)
     while message.is_next_element:
         element = message.next_element
         time = element.payload
         key = element.key
         self.stored_data.append((key, time))
         print(f"Received key {hex(key)} at time {time}")
    def receive_eieio_message(self, timeout=None):
        data = self.receive(timeout)
        header = struct.unpack_from("<H", data)[0]
        if header & 0xC000 == 0x4000:
            eieio_message = read_eieio_command_message(data, 0)
        else:
            eieio_message = read_eieio_data_message(data, 0)

        return eieio_message
 def from_bytestring(command_header, data, offset):
     region_id, sequence_no = struct.unpack_from("<BB", data, offset)
     eieio_data_message = read_eieio_data_message(data, offset)
     return HostSendSequencedData(region_id, sequence_no,
                                  eieio_data_message)
Example #4
0
    128: 'Ball',
    129: 'Glass',
    130: 'Plate',
    131: 'Tablet',
    132: 'Notebook',
    133: 'paper',
    134: 'cup',
    135: 'box',
    136: 'pen',
    137: 'camera',
    }

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))

while True:
    data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
    data_bytearray = bytearray(data)
    byte_reader_msg = byte_reader.LittleEndianByteArrayByteReader(data_bytearray)
    packet = parse_msg.read_eieio_data_message(byte_reader_msg)
    n_keys = packet.n_elements
    for i in xrange(n_keys):
        key = packet.next_element.key
        if key not in association:
            print "I don't know what this means:", key
        else:
            print association[key]
            say(association[key])
    print "\n"
Example #5
0
 def from_bytestring(command_header, data, offset):  # @UnusedVariable
     region_id, sequence_no = _PATTERN_BB.unpack_from(data, offset)
     eieio_data_message = read_eieio_data_message(data, offset)
     return HostSendSequencedData(
         region_id, sequence_no, eieio_data_message)
 def from_bytestring(command_header, data, offset):
     region_id, sequence_no = struct.unpack_from("<BB", data, offset)
     eieio_data_message = read_eieio_data_message(data, offset)
     return HostSendSequencedData(region_id, sequence_no,
                                  eieio_data_message)