Esempio n. 1
0
    def read(self, addr, length=None):
        length_int = 1 if length is None else length
        record = EtherboneRecord()
        record.reads = EtherboneReads(addrs=[addr+4*j for j in range(length_int)])
        record.rcount = len(record.reads)

        packet = EtherbonePacket()
        packet.records = [record]
        packet.encode()
        self.tx_socket.sendto(bytes(packet), (self.server, self.port))

        datas, dummy = self.rx_socket.recvfrom(8192)
        packet = EtherbonePacket(datas)
        packet.decode()
        datas = packet.records.pop().writes.get_datas()
        if self.debug:
            for i, value in enumerate(datas):
                print("read {:08x} @ {:08x}".format(value, addr + 4*i))
        return datas[0] if length is None else datas
Esempio n. 2
0
    def read(self, addr, length=None):
        length_int = 1 if length is None else length
        record = EtherboneRecord()
        record.reads = EtherboneReads(addrs=[addr+4*j for j in range(length_int)])
        record.rcount = len(record.reads)

        packet = EtherbonePacket()
        packet.records = [record]
        packet.encode()
        self.tx_socket.sendto(bytes(packet), (self.server, self.port))

        datas, dummy = self.rx_socket.recvfrom(8192)
        packet = EtherbonePacket(datas)
        packet.decode()
        datas = packet.records.pop().writes.get_datas()
        if self.debug:
            for i, value in enumerate(datas):
                print("read {:08x} @ {:08x}".format(value, addr + 4*i))
        return datas[0] if length is None else datas
Esempio n. 3
0
    def read(self, addr, length=None):
        length_int = 1 if length is None else length
        # prepare packet
        record = EtherboneRecord()
        record.reads = EtherboneReads(addrs=[addr + 4*j for j in range(length_int)])
        record.rcount = len(record.reads)

        # send packet
        packet = EtherbonePacket()
        packet.records = [record]
        packet.encode()
        self.send_packet(self.socket, packet[:])

        # receive response
        packet = EtherbonePacket(self.receive_packet(self.socket))
        packet.decode()
        datas = packet.records.pop().writes.get_datas()
        if self.debug:
            for i, data in enumerate(datas):
                print("read {:08x} @ {:08x}".format(data, addr + 4*i))
        return datas[0] if length is None else datas
Esempio n. 4
0
    def read(self, addr, length=None):
        length_int = 1 if length is None else length
        # prepare packet
        record = EtherboneRecord()
        record.reads = EtherboneReads(
            addrs=[addr + 4 * j for j in range(length_int)])
        record.rcount = len(record.reads)

        # send packet
        packet = EtherbonePacket()
        packet.records = [record]
        packet.encode()
        self.send_packet(self.socket, packet[:])

        # receive response
        packet = EtherbonePacket(self.receive_packet(self.socket))
        packet.decode()
        datas = packet.records.pop().writes.get_datas()
        if self.debug:
            for i, data in enumerate(datas):
                print("read {:08x} @ {:08x}".format(data, addr + 4 * i))
        return datas[0] if length is None else datas