tools/litex_client: Add binded property to simplify user scripts.
This commit is contained in:
parent
34ec22f8ab
commit
8f26e5f7a8
|
@ -34,6 +34,7 @@ class RemoteClient(EtherboneIPC, CSRBuilder):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
self.port = port
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
|
self.binded = False
|
||||||
self.base_address = base_address if base_address is not None else 0
|
self.base_address = base_address if base_address is not None else 0
|
||||||
|
|
||||||
def _receive_server_info(self):
|
def _receive_server_info(self):
|
||||||
|
@ -44,17 +45,19 @@ class RemoteClient(EtherboneIPC, CSRBuilder):
|
||||||
self.base_address = -self.mems.csr.base
|
self.base_address = -self.mems.csr.base
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
if hasattr(self, "socket"):
|
if self.binded:
|
||||||
return
|
return
|
||||||
self.socket = socket.create_connection((self.host, self.port), 5.0)
|
self.socket = socket.create_connection((self.host, self.port), 5.0)
|
||||||
self.socket.settimeout(5.0)
|
self.socket.settimeout(5.0)
|
||||||
self._receive_server_info()
|
self._receive_server_info()
|
||||||
|
self.binded = True
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if not hasattr(self, "socket"):
|
if not self.binded:
|
||||||
return
|
return
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
del self.socket
|
del self.socket
|
||||||
|
self.binded = False
|
||||||
|
|
||||||
def read(self, addr, length=None, burst="incr"):
|
def read(self, addr, length=None, burst="incr"):
|
||||||
length_int = 1 if length is None else length
|
length_int = 1 if length is None else length
|
||||||
|
|
Loading…
Reference in New Issue