litex_server: allow setting bind port, remove auto-incrementing on bind_port
This commit is contained in:
parent
76bc57851b
commit
db11aec961
|
@ -12,23 +12,18 @@ from litex.soc.tools.remote.etherbone import EtherboneIPC
|
||||||
|
|
||||||
|
|
||||||
class RemoteServer(EtherboneIPC):
|
class RemoteServer(EtherboneIPC):
|
||||||
def __init__(self, comm, bind, port=1234):
|
def __init__(self, comm, bind_ip, bind_port=1234):
|
||||||
self.comm = comm
|
self.comm = comm
|
||||||
self.bind = bind
|
self.bind_ip = bind_ip
|
||||||
self.port = port
|
self.bind_port = bind_port
|
||||||
self.lock = False
|
self.lock = False
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
if hasattr(self, "socket"):
|
if hasattr(self, "socket"):
|
||||||
return
|
return
|
||||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
for i in range(32):
|
self.socket.bind((self.bind_ip, self.bind_port))
|
||||||
try:
|
print("tcp port: {:d}".format(self.bind_port))
|
||||||
self.socket.bind((bind, self.port + i))
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
print("tcp port: {:d}".format(self.port + i))
|
|
||||||
self.socket.listen(1)
|
self.socket.listen(1)
|
||||||
self.comm.open()
|
self.comm.open()
|
||||||
|
|
||||||
|
@ -100,8 +95,10 @@ def main():
|
||||||
print("LiteX remote server")
|
print("LiteX remote server")
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
# Common arguments
|
# Common arguments
|
||||||
parser.add_argument("--bind", default="localhost",
|
parser.add_argument("--bind-ip", default="localhost",
|
||||||
help="Host binding address")
|
help="Host bind address")
|
||||||
|
parser.add_argument("--bind-port", default=1234,
|
||||||
|
help="Host bind port")
|
||||||
|
|
||||||
# UART arguments
|
# UART arguments
|
||||||
parser.add_argument("--uart", action="store_true",
|
parser.add_argument("--uart", action="store_true",
|
||||||
|
@ -148,7 +145,7 @@ def main():
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
server = RemoteServer(comm, args.bind)
|
server = RemoteServer(comm, args.bind_ip, int(args.bind_port))
|
||||||
server.open()
|
server.open()
|
||||||
server.start(4)
|
server.start(4)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue