From: Florent Kermarrec Date: Fri, 22 Nov 2019 14:28:35 +0000 (+0100) Subject: tools/remote/comm_udp: only use one socket X-Git-Tag: 24jan2021_ls180~841 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de205d4a8457d0c226d69ae93f30a47d0ebcc1d1;p=litex.git tools/remote/comm_udp: only use one socket --- diff --git a/litex/tools/remote/comm_udp.py b/litex/tools/remote/comm_udp.py index 7a74aae0..60794c9c 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):