From de205d4a8457d0c226d69ae93f30a47d0ebcc1d1 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 22 Nov 2019 15:28:35 +0100 Subject: [PATCH] tools/remote/comm_udp: only use one socket --- litex/tools/remote/comm_udp.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/litex/tools/remote/comm_udp.py b/litex/tools/remote/comm_udp.py index 7a74aae08..60794c9c3 100644 --- a/litex/tools/remote/comm_udp.py +++ b/litex/tools/remote/comm_udp.py @@ -17,17 +17,14 @@ class CommUDP: def open(self): if hasattr(self, "tx_socket"): return - self.tx_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.rx_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.rx_socket.bind(("", self.port)) + self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + self.socket.bind(("", self.port)) def close(self): if not hasattr(self, "tx_socket"): return - self.tx_socket.close() - del self.tx_socket - self.rx_socket.close() - del self.rx_socket + self.socket.close() + del self.socket def read(self, addr, length=None): length_int = 1 if length is None else length @@ -38,9 +35,9 @@ class CommUDP: packet = EtherbonePacket() packet.records = [record] packet.encode() - self.tx_socket.sendto(bytes(packet), (self.server, self.port)) + self.socket.sendto(bytes(packet), (self.server, self.port)) - datas, dummy = self.rx_socket.recvfrom(8192) + datas, dummy = self.socket.recvfrom(8192) packet = EtherbonePacket(datas) packet.decode() datas = packet.records.pop().writes.get_datas() @@ -59,7 +56,7 @@ class CommUDP: packet = EtherbonePacket() packet.records = [record] packet.encode() - self.tx_socket.sendto(bytes(packet), (self.server, self.port)) + self.socket.sendto(bytes(packet), (self.server, self.port)) if self.debug: for i, value in enumerate(datas):