Skip to content

Commit

Permalink
Add option to accept comms with FSW running TCP server (#137)
Browse files Browse the repository at this point in the history
* Add option to accept comms with FSW as TCP server

* rename option
  • Loading branch information
thomas-bc authored Aug 14, 2023
1 parent 928a264 commit a0807c7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/fprime_gds/common/communication/adapters/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 servers unless server=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()
Expand Down Expand Up @@ -171,6 +171,14 @@ def get_arguments(cls):
"default": 50000,
"help": "Port of the IP adapter server. Default: %(default)s",
},
("--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 (connects to FSW running TcpServer)",
},
}

@classmethod
Expand Down

0 comments on commit a0807c7

Please sign in to comment.