From 96dd25f02f727ada49ce99160f8b198fe78bb271 Mon Sep 17 00:00:00 2001 From: thomas-bc Date: Wed, 9 Aug 2023 18:37:50 -0700 Subject: [PATCH 1/2] Add option to accept comms with FSW as TCP server --- src/fprime_gds/common/communication/adapters/ip.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/fprime_gds/common/communication/adapters/ip.py b/src/fprime_gds/common/communication/adapters/ip.py index 9150c063..d07d74fb 100644 --- a/src/fprime_gds/common/communication/adapters/ip.py +++ b/src/fprime_gds/common/communication/adapters/ip.py @@ -54,17 +54,17 @@ class IpAdapter(fprime_gds.common.communication.adapters.base.BaseAdapter): KEEPALIVE_DATA = b"sitting well" MAXIMUM_DATA_SIZE = 4096 - def __init__(self, address, port): + def __init__(self, address, port, server=True): """ Initialize this adapter by creating a handler for UDP and TCP. A thread for the KEEPALIVE application packets - will be created, if the interval is not none. + will be created, if the interval is not none. Handlers are created as clients if server is set to false. """ self.address = address self.port = port self.stop = False self.keepalive = None - self.tcp = TcpHandler(address, port) - self.udp = UdpHandler(address, port) + self.tcp = TcpHandler(address, port, server=server) + self.udp = UdpHandler(address, port, server=server) self.thtcp = None self.thudp = None self.data_chunks = queue.Queue() @@ -171,6 +171,12 @@ def get_arguments(cls): "default": 50000, "help": "Port of the IP adapter server. Default: %(default)s", }, + ("--fsw-server",): { + "dest": "server", + "action": "store_false", + "default": True, + "help": "Run the IP adapter as the client (meaning FSW is the TCP Server).", + }, } @classmethod From f590fbcad881a7e7ad60cf061200a9683d97eb84 Mon Sep 17 00:00:00 2001 From: thomas-bc Date: Thu, 10 Aug 2023 10:53:02 -0700 Subject: [PATCH 2/2] rename option --- src/fprime_gds/common/communication/adapters/ip.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/fprime_gds/common/communication/adapters/ip.py b/src/fprime_gds/common/communication/adapters/ip.py index d07d74fb..71e73743 100644 --- a/src/fprime_gds/common/communication/adapters/ip.py +++ b/src/fprime_gds/common/communication/adapters/ip.py @@ -57,7 +57,7 @@ class IpAdapter(fprime_gds.common.communication.adapters.base.BaseAdapter): def __init__(self, address, port, server=True): """ Initialize this adapter by creating a handler for UDP and TCP. A thread for the KEEPALIVE application packets - will be created, if the interval is not none. Handlers are created as clients if server is set to false. + will be created, if the interval is not none. Handlers are servers unless server=False. """ self.address = address self.port = port @@ -171,11 +171,13 @@ def get_arguments(cls): "default": 50000, "help": "Port of the IP adapter server. Default: %(default)s", }, - ("--fsw-server",): { + ("--ip-client",): { + # dest is "server" since it is handled in BaseAdapter.construct_adapter and passed with the same + # name to the IpAdapter constructor. Default to server=True, meaning IpAdapter is the TCP server "dest": "server", "action": "store_false", "default": True, - "help": "Run the IP adapter as the client (meaning FSW is the TCP Server).", + "help": "Run the IP adapter as the client (connects to FSW running TcpServer)", }, }